fix(leaderboard): align leaderboard API response parsing and podium rankings
@Rithish-2914 đang làm issue này rồi.
Từ ngày 18/9/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Problem
Problem
The Admin Leaderboard page (/leaderboard) fails to display participant rankings and podium standings due to API response structure mismatches:
-
Empty Leaderboard & Undefined Data:
getLeaderboard()insrc/api/users.tsexpects{ status: string, leaderboard: LeaderboardUser[] }and returnsresponse.data.leaderboard.- The backend
GET /admin/leaderboardreturns{ "message": "Leaderboard fetched successfully", "data": [ LeaderboardEntry... ] }. - Because
response.data.leaderboardisundefined, the query returnsundefined, leaving the podium and rest-of-the-field rankings blank.
-
Field Mapping:
- Backend returns
rank,id,name,email,reg_no,score,round_qualified,total_runtime,total_submissions,solved_count,is_banned. - Frontend accessors require clean mapping into
LeaderboardUserrecords.
- Backend returns
-
Podium Edge Cases:
- The top 3 podium layout should gracefully handle cases where fewer than 3 users have submitted solutions.
Steps to Reproduce
- Start the backend and log into the Admin portal (
cookoff-admin-11.0). - Navigate to the Leader tab from the sidebar (
/leaderboard). - Observed Behavior: The leaderboard displays "No other participants yet" or an empty state because
response.data.leaderboardisundefined. - Inspect Network tab for
GET /admin/leaderboard: the backend returns{ "message": "...", "data": [...] }with snake_case fields. - Expected Behavior: Top 3 participants should be highlighted on the podium with gold/silver/bronze trophies, scores, and rankings, with the remaining participants listed in "The Rest of the Field" table.
Proposed solution
src/api/users.ts:- Define
RawLeaderboardEntryandnormalizeLeaderboardUserhelper. - Update
getLeaderboard()to unwrapresponse.data.datainto normalizedLeaderboardUser[].
- Define
src/app/(protected)/leaderboard/page.tsx:- Ensure podium and field rankings consume normalized properties safely.
- Unit Tests:
- Add unit test coverage in
src/api/__tests__/users.test.tsforgetLeaderboardandnormalizeLeaderboardUser.
- Add unit test coverage in
Alternatives considered
No response
- Ngôn ngữ chính
- TypeScript
- Star
- 0
- Fork
- 1
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CodeChefVIT/cookoff-admin-11.0
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
fix(submissions): consume flat UserSubmissionResponse[] instead of nested .submission/.resultsĐang mởenhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
-
fix(users): add target round and role payload to user upgrade endpointCó thể làm lại được @Rithish-2914 đã nhận 54 ngày trước và không có pull request nào đang mở. Đang mởenhancement
CodeChefVIT/cookoff-admin-11.0#22 · 1 người được giao ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
Tất cả issue của CodeChefVIT/cookoff-admin-11.0
Issue tương tự
-
nb stats: the high-error-rate anomaly and the error-causes line give different cause splits for the same errorsCó thể đã có người làm @jeanibarz đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 89/100
jeanibarz/agent-notebook#418 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Page sections overlap each other on every page (e.g. Seasons, Actors and Reviews on show pages)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
josephfung/curia#2563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
README demo: offer a controlled video variant next to the GIF for reduced motion and mobile dataĐang mởaccessibility
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
onetechgroupll/eigen-beam#26 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
maintenance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
killi199/time-tracking#532 ·
Maintainer thường phản hồi trong vòng 1 ngày