Skip to content

District competitions leaderboard page at /districts/id]/leaderboard #423

Open
clintjeff2 wants to merge 2 commits into
Bitcoindefi:mainfrom
clintjeff2:District-competitions-leaderboard-page-at-/districts/id]/leaderboard-#185
Open

District competitions leaderboard page at /districts/id]/leaderboard #423
clintjeff2 wants to merge 2 commits into
Bitcoindefi:mainfrom
clintjeff2:District-competitions-leaderboard-page-at-/districts/id]/leaderboard-#185

Conversation

@clintjeff2

Copy link
Copy Markdown
Contributor

Motivation

  • Surface the weekly district competition scores that were previously computed only on-demand so users can see a per-district leaderboard and countdown to week reset.
  • Provide a place to show previous-week snapshots (when available) and link from the city map/district overlay to the district leaderboard pages.

Description

  • Add the new dynamic route for district leaderboards at app/districts/[id]/leaderboard/page.tsx which renders the top-10 agents for the current week with columns for rank, agent name, score, tasks completed this week, and district, and includes a responsive overflow table.
  • Add a client CountdownTimer component at components/districts/countdown-timer.tsx that updates every second against the event endsAt timestamp.
  • Add lib/gamification/district-leaderboard.ts to compute per-district top-10 results and to read JSON-backed previous-week snapshots from data/district-leaderboard-snapshots.json.
  • Export/reuse helpers in lib/gamification/events.ts (getWeekBounds, formatDistrictScore, getAgentDistrictCompetitionScore, getWeeklyTasksCompleted) and adjust epoch/week calculation to align weekly boundaries; update the map overlay at components/open-stellar/district-event-overlay.tsx to link each district to its leaderboard.

Testing

  • Ran npm run lint which reported pre-existing lint problems in unrelated files and did not pass (errors/warnings unrelated to this change).
  • Ran npm test (Vitest): 82 test files and 533 tests ran successfully before the run failed overall due to a missing package (lru-cache) causing tests/skills/versioning.test.ts to fail; the new leaderboard code did not cause unit test regressions prior to that failure.
  • Ran npx tsc --noEmit which failed due to missing dependencies (lru-cache and @wagmi/connectors) in the local environment rather than from the changes in this PR.

Closes #185

@sonarqubecloud

Copy link
Copy Markdown

@clintjeff2

Copy link
Copy Markdown
Contributor Author

@leocagli, review and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

District competitions: leaderboard page at /districts/[id]/leaderboard

1 participant