Skip to content

Commit 774383c

Browse files
committed
remove leaderboard and active projects feature
1 parent 86ec4e0 commit 774383c

File tree

9 files changed

+0
-568
lines changed

9 files changed

+0
-568
lines changed

Diff for: src/graphql/mutations.rs

-104
Original file line numberDiff line numberDiff line change
@@ -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
}

Diff for: src/graphql/query.rs

-56
Original file line numberDiff line numberDiff line change
@@ -27,62 +27,6 @@ impl QueryRoot {
2727
Ok(users)
2828
}
2929

30-
async fn get_unified_leaderboard(
31-
&self,
32-
ctx: &Context<'_>,
33-
) -> Result<Vec<LeaderboardWithMember>, sqlx::Error> {
34-
let pool = ctx
35-
.data::<Arc<PgPool>>()
36-
.expect("Pool not found in context");
37-
let leaderboard = sqlx::query_as::<_, LeaderboardWithMember>(
38-
"SELECT l.*, m.name AS member_name
39-
FROM leaderboard l
40-
JOIN member m ON l.member_id = m.id
41-
ORDER BY unified_score DESC",
42-
)
43-
.fetch_all(pool.as_ref())
44-
.await?;
45-
Ok(leaderboard)
46-
}
47-
48-
async fn get_leetcode_stats(
49-
&self,
50-
ctx: &Context<'_>,
51-
) -> Result<Vec<LeetCodeStatsWithName>, sqlx::Error> {
52-
let pool = ctx
53-
.data::<Arc<PgPool>>()
54-
.expect("Pool not found in context");
55-
let leetcode_stats = sqlx::query_as::<_, LeetCodeStatsWithName>(
56-
"SELECT l.*, m.name AS member_name
57-
FROM leetcode_stats l
58-
JOIN member m ON l.member_id = m.id
59-
ORDER BY best_rank
60-
",
61-
)
62-
.fetch_all(pool.as_ref())
63-
.await?;
64-
Ok(leetcode_stats)
65-
}
66-
67-
async fn get_codeforces_stats(
68-
&self,
69-
ctx: &Context<'_>,
70-
) -> Result<Vec<CodeforcesStatsWithName>, sqlx::Error> {
71-
// let pool = ctx.data::<PgPool>()?;
72-
let pool = ctx
73-
.data::<Arc<PgPool>>()
74-
.expect("Pool not found in context");
75-
let codeforces_stats = sqlx::query_as::<_, CodeforcesStatsWithName>(
76-
"SELECT c.*, m.name AS member_name
77-
FROM codeforces_stats c
78-
JOIN member m ON c.member_id = m.id
79-
ORDER BY max_rating DESC",
80-
)
81-
.fetch_all(pool.as_ref())
82-
.await?;
83-
Ok(codeforces_stats)
84-
}
85-
8630
//Query for retrieving the attendance based on date
8731
async fn get_attendance(
8832
&self,

Diff for: src/leaderboard/fetch_stats.rs

-180
This file was deleted.

Diff for: src/leaderboard/mod.rs

-2
This file was deleted.

0 commit comments

Comments
 (0)