Skip to content

Commit dcab05c

Browse files
committed
Updated leaderboard display backend requests to use query parameters; Offset calculation shifted from backend to frontend
1 parent f845af9 commit dcab05c

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/commons/sagas/RequestsSaga.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,16 @@ export const getAllTotalXp = async (tokens: Tokens): Promise<number | null> => {
489489
};
490490

491491
/**
492-
* GET /courses/{courseId}/get_paginated_display/:page/:page_size
492+
* GET /courses/{courseId}/get_paginated_display
493493
*/
494494
export const getPaginatedTotalXp = async (
495495
page: number,
496496
pageSize: number,
497497
tokens: Tokens
498498
): Promise<{ rows: LeaderboardRow[]; userCount: number } | null> => {
499-
const resp = await request(`${courseId()}/get_paginated_display/${page}/${pageSize}`, 'GET', {
499+
const offset = (page - 1) * pageSize
500+
const params = new URLSearchParams({'offset': `${offset}`, 'page_size': `${pageSize}`});
501+
const resp = await request(`${courseId()}/get_paginated_display?${params.toString()}`, 'GET', {
500502
...tokens
501503
});
502504

@@ -521,15 +523,16 @@ export const getPaginatedTotalXp = async (
521523
};
522524

523525
/**
524-
* GET /courses/{courseId}/assessments/{assessmentid}/{visibleentries}/scoreLeaderboard
526+
* GET /courses/{courseId}/assessments/{assessmentid}/scoreLeaderboard
525527
*/
526528
export const getContestScoreLeaderboard = async (
527529
assessmentId: number,
528530
visibleEntries: number,
529531
tokens: Tokens
530532
): Promise<ContestLeaderboardRow[] | null> => {
533+
const params = new URLSearchParams({'visible_entries': `${visibleEntries}`})
531534
const resp = await request(
532-
`${courseId()}/assessments/${assessmentId}/${visibleEntries}/scoreLeaderboard`,
535+
`${courseId()}/assessments/${assessmentId}/scoreLeaderboard?${params.toString()}`,
533536
'GET',
534537
{
535538
...tokens
@@ -557,15 +560,16 @@ export const getContestScoreLeaderboard = async (
557560
};
558561

559562
/**
560-
* GET /courses/{courseId}/assessments/{assessmentid}/{visibleentries}/popularVoteLeaderboard
563+
* GET /courses/{courseId}/assessments/{assessmentid}/popularVoteLeaderboard
561564
*/
562565
export const getContestPopularVoteLeaderboard = async (
563566
assessmentId: number,
564567
visibleEntries: number,
565568
tokens: Tokens
566569
): Promise<ContestLeaderboardRow[] | null> => {
570+
const params = new URLSearchParams({'visible_entries': `${visibleEntries}`})
567571
const resp = await request(
568-
`${courseId()}/assessments/${assessmentId}/${visibleEntries}/popularVoteLeaderboard`,
572+
`${courseId()}/assessments/${assessmentId}/popularVoteLeaderboard?${params.toString()}`,
569573
'GET',
570574
{
571575
...tokens
@@ -1332,15 +1336,16 @@ export const dispatchContestXp = async (
13321336
};
13331337

13341338
/**
1335-
* GET /courses/{courseId}/assessments/{assessmentId}/{visibleEntries}/scoreLeaderboard
1339+
* GET /courses/{courseId}/admin/assessments/{assessmentId}/scoreLeaderboard
13361340
*/
13371341
export const getScoreLeaderboard = async (
13381342
assessmentId: number,
13391343
visibleEntries: number | undefined,
13401344
tokens: Tokens
13411345
): Promise<ContestEntry[] | null> => {
1346+
const params = new URLSearchParams({'visible_entries': `${visibleEntries}`})
13421347
const resp = await request(
1343-
`${courseId()}/assessments/${assessmentId}/${visibleEntries}/scoreLeaderboard`,
1348+
`${courseId()}/admin/assessments/${assessmentId}/scoreLeaderboard?${params.toString()}`,
13441349
'GET',
13451350
{
13461351
...tokens
@@ -1363,15 +1368,16 @@ export const getScoreLeaderboard = async (
13631368
};
13641369

13651370
/**
1366-
* GET /courses/{courseId}/admin/assessments/{assessmentId}/{visibleEntries}/popularVoteLeaderboard
1371+
* GET /courses/{courseId}/admin/assessments/{assessmentId}/popularVoteLeaderboard
13671372
*/
13681373
export const getPopularVoteLeaderboard = async (
13691374
assessmentId: number,
13701375
visibleEntries: number | undefined,
13711376
tokens: Tokens
13721377
): Promise<ContestEntry[] | null> => {
1378+
const params = new URLSearchParams({'visible_entries': `${visibleEntries}`})
13731379
const resp = await request(
1374-
`${courseId()}/admin/assessments/${assessmentId}/${visibleEntries}/popularVoteLeaderboard`,
1380+
`${courseId()}/admin/assessments/${assessmentId}/popularVoteLeaderboard?${params.toString()}`,
13751381
'GET',
13761382
{
13771383
...tokens

0 commit comments

Comments
 (0)