import { NextRequest, NextResponse } from 'next/server';
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

export async function POST(req: NextRequest) {
    try {
        // Reset all song ratings to 0
        const result = await prisma.song.updateMany({
            data: {
                averageRating: 0,
                ratingCount: 0,
            },
        });

        return NextResponse.json({
            success: true,
            message: `Successfully reset ratings for ${result.count} songs`,
            count: result.count,
        });
    } catch (error) {
        console.error('Error resetting ratings:', error);
        return NextResponse.json(
            { error: 'Failed to reset ratings' },
            { status: 500 }
        );
    }
}
