@@ -14,7 +14,6 @@ use root::models::{
1414 attendance:: Attendance ,
1515 leaderboard:: { CodeforcesStats , LeetCodeStats } ,
1616 member:: Member ,
17- member:: StreakUpdate ,
1817 projects:: ActiveProjects ,
1918} ;
2019
@@ -205,61 +204,6 @@ impl MutationRoot {
205204 Ok ( attendance)
206205 }
207206
208- //here when user changes the handle, it just updates the handle in the database without updating the other values till midnight
209-
210- async fn add_or_update_leetcode_username (
211- & self ,
212- ctx : & Context < ' _ > ,
213- member_id : i32 ,
214- username : String ,
215- ) -> Result < LeetCodeStats , sqlx:: Error > {
216- let pool = ctx
217- . data :: < Arc < PgPool > > ( )
218- . expect ( "Pool not found in context" ) ;
219-
220- let result = sqlx:: query_as :: < _ , LeetCodeStats > (
221- "
222- INSERT INTO leetcode_stats (member_id, leetcode_username, problems_solved, easy_solved, medium_solved, hard_solved, contests_participated, best_rank, total_contests)
223- VALUES ($1, $2, 0, 0, 0, 0, 0, 0, 0)
224- ON CONFLICT (member_id) DO UPDATE
225- SET leetcode_username = $2
226- RETURNING *
227- "
228- )
229- . bind ( member_id)
230- . bind ( username)
231- . fetch_one ( pool. as_ref ( ) )
232- . await ?;
233-
234- Ok ( result)
235- }
236-
237- async fn add_or_update_codeforces_handle (
238- & self ,
239- ctx : & Context < ' _ > ,
240- member_id : i32 ,
241- handle : String ,
242- ) -> Result < CodeforcesStats , sqlx:: Error > {
243- let pool = ctx
244- . data :: < Arc < PgPool > > ( )
245- . expect ( "Pool not found in context" ) ;
246-
247- let result = sqlx:: query_as :: < _ , CodeforcesStats > (
248- "
249- INSERT INTO codeforces_stats (member_id, codeforces_handle, codeforces_rating, max_rating, contests_participated)
250- VALUES ($1, $2, 0, 0, 0)
251- ON CONFLICT (member_id) DO UPDATE
252- SET codeforces_handle = $2
253- RETURNING *
254- "
255- )
256- . bind ( member_id)
257- . bind ( handle)
258- . fetch_one ( pool. as_ref ( ) )
259- . await ?;
260-
261- Ok ( result)
262- }
263207 async fn update_streak (
264208 & self ,
265209 ctx : & Context < ' _ > ,
@@ -326,52 +270,4 @@ impl MutationRoot {
326270 }
327271 }
328272 }
329-
330- async fn set_active_project (
331- & self ,
332- ctx : & Context < ' _ > ,
333- id : i32 ,
334- project_name : String ,
335- ) -> Result < ActiveProjects , sqlx:: Error > {
336- let pool = ctx
337- . data :: < Arc < PgPool > > ( )
338- . expect ( "Pool not found in context" ) ;
339-
340- let active_project = sqlx:: query_as :: < _ , ActiveProjects > (
341- "
342- INSERT INTO ActiveProjects (member_id,project_title)
343- VALUES ($1,$2)
344- RETURNING *
345- " ,
346- )
347- . bind ( id)
348- . bind ( project_name)
349- . fetch_one ( pool. as_ref ( ) )
350- . await ?;
351-
352- Ok ( active_project)
353- }
354-
355- async fn remove_active_project (
356- & self ,
357- ctx : & Context < ' _ > ,
358- project_id : i32 ,
359- ) -> Result < ActiveProjects , sqlx:: Error > {
360- let pool = ctx
361- . data :: < Arc < PgPool > > ( )
362- . expect ( "Pool not found in context" ) ;
363-
364- let active_project = sqlx:: query_as :: < _ , ActiveProjects > (
365- "
366- DELETE FROM ActiveProjects
367- WHERE id = $1
368- RETURNING *
369- " ,
370- )
371- . bind ( project_id)
372- . fetch_one ( pool. as_ref ( ) )
373- . await ?;
374-
375- Ok ( active_project)
376- }
377273}
0 commit comments