fix(leaderboard): align leaderboard API response parsing and podium rankings

オープン
#19 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

@Rithish-2914 がすでに取り組んでいます。

2026年9月18日 から。

評価

この issue はまだ評価されていません。

説明

enhancement
Problem
Problem

The Admin Leaderboard page (/leaderboard) fails to display participant rankings and podium standings due to API response structure mismatches:

  1. Empty Leaderboard & Undefined Data:

    • getLeaderboard() in src/api/users.ts expects { status: string, leaderboard: LeaderboardUser[] } and returns response.data.leaderboard.
    • The backend GET /admin/leaderboard returns { "message": "Leaderboard fetched successfully", "data": [ LeaderboardEntry... ] }.
    • Because response.data.leaderboard is undefined, the query returns undefined, leaving the podium and rest-of-the-field rankings blank.
  2. 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 LeaderboardUser records.
  3. Podium Edge Cases:

    • The top 3 podium layout should gracefully handle cases where fewer than 3 users have submitted solutions.

Steps to Reproduce
  1. Start the backend and log into the Admin portal (cookoff-admin-11.0).
  2. Navigate to the Leader tab from the sidebar (/leaderboard).
  3. Observed Behavior: The leaderboard displays "No other participants yet" or an empty state because response.data.leaderboard is undefined.
  4. Inspect Network tab for GET /admin/leaderboard: the backend returns { "message": "...", "data": [...] } with snake_case fields.
  5. 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
  1. src/api/users.ts:
    • Define RawLeaderboardEntry and normalizeLeaderboardUser helper.
    • Update getLeaderboard() to unwrap response.data.data into normalized LeaderboardUser[].
  2. src/app/(protected)/leaderboard/page.tsx:
    • Ensure podium and field rankings consume normalized properties safely.
  3. Unit Tests:
    • Add unit test coverage in src/api/__tests__/users.test.ts for getLeaderboard and normalizeLeaderboardUser.
Alternatives considered

No response

主要言語
TypeScript
スター
0
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CodeChefVIT/cookoff-admin-11.0 のほかの issue

CodeChefVIT/cookoff-admin-11.0 の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。