@@ -35,9 +35,9 @@ const fetchLeetCodeStats = async (username: string) => {
35
35
} ;
36
36
37
37
// Store transformed user stats in Supabase
38
- const storeUserStats = async ( userId : string , stats : any ) => {
38
+ const storeUserStats = async ( id : string , stats : any ) => {
39
39
const entry = {
40
- user_id : String ( userId ) ,
40
+ id : String ( id ) ,
41
41
ranking : stats . profile . ranking ,
42
42
solved_easy : stats . submitStats . acSubmissionNum . find ( ( item : any ) => item . difficulty === 'Easy' ) ?. count || "0" ,
43
43
solved_medium : stats . submitStats . acSubmissionNum . find ( ( item : any ) => item . difficulty === 'Medium' ) ?. count || "0" ,
@@ -73,10 +73,10 @@ const transformLeetCodeData = (stats: any) => {
73
73
export async function POST ( req : NextRequest , res : NextResponse ) {
74
74
const searchParams = req . nextUrl . searchParams ;
75
75
const username = searchParams . get ( 'username' ) ;
76
- const userId = searchParams . get ( 'userId ' ) ;
76
+ const id = searchParams . get ( 'id ' ) ;
77
77
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 } ) ;
80
80
}
81
81
82
82
const stats = await fetchLeetCodeStats ( username ) ;
@@ -87,9 +87,7 @@ export async function POST(req: NextRequest, res: NextResponse) {
87
87
88
88
const transformedStats = transformLeetCodeData ( stats ) ;
89
89
90
- console . log ( 'Transformed Stats:' , JSON . stringify ( transformedStats , null , 2 ) ) ;
91
-
92
- await storeUserStats ( userId , transformedStats ) ;
90
+ await storeUserStats ( id , transformedStats ) ;
93
91
94
92
return NextResponse . json ( { message : "Success" , stats :transformedStats } ) ;
95
93
}
0 commit comments