@@ -35,9 +35,9 @@ const fetchLeetCodeStats = async (username: string) => {
3535} ;
3636
3737// Store transformed user stats in Supabase
38- const storeUserStats = async ( userId : string , stats : any ) => {
38+ const storeUserStats = async ( id : string , stats : any ) => {
3939 const entry = {
40- user_id : String ( userId ) ,
40+ id : String ( id ) ,
4141 ranking : stats . profile . ranking ,
4242 solved_easy : stats . submitStats . acSubmissionNum . find ( ( item : any ) => item . difficulty === 'Easy' ) ?. count || "0" ,
4343 solved_medium : stats . submitStats . acSubmissionNum . find ( ( item : any ) => item . difficulty === 'Medium' ) ?. count || "0" ,
@@ -73,10 +73,10 @@ const transformLeetCodeData = (stats: any) => {
7373export async function POST ( req : NextRequest , res : NextResponse ) {
7474 const searchParams = req . nextUrl . searchParams ;
7575 const username = searchParams . get ( 'username' ) ;
76- const userId = searchParams . get ( 'userId ' ) ;
76+ const id = searchParams . get ( 'id ' ) ;
7777
78- if ( ! username || ! userId ) {
79- return NextResponse . json ( { error : "Username and userId are required" } , { status : 400 } ) ;
78+ if ( ! username || ! id ) {
79+ return NextResponse . json ( { error : "Username and id are required" } , { status : 400 } ) ;
8080 }
8181
8282 const stats = await fetchLeetCodeStats ( username ) ;
@@ -87,9 +87,7 @@ export async function POST(req: NextRequest, res: NextResponse) {
8787
8888 const transformedStats = transformLeetCodeData ( stats ) ;
8989
90- console . log ( 'Transformed Stats:' , JSON . stringify ( transformedStats , null , 2 ) ) ;
91-
92- await storeUserStats ( userId , transformedStats ) ;
90+ await storeUserStats ( id , transformedStats ) ;
9391
9492 return NextResponse . json ( { message : "Success" , stats :transformedStats } ) ;
9593}
0 commit comments