Skip to content

Leaderboard wire up live data from agent registry (replaces mock data) #419

Open
clintjeff2 wants to merge 2 commits into
Bitcoindefi:mainfrom
clintjeff2:Leaderboard-wire-up-live-data-from-agent-registry-(replaces-mock-data)-#195
Open

Leaderboard wire up live data from agent registry (replaces mock data) #419
clintjeff2 wants to merge 2 commits into
Bitcoindefi:mainfrom
clintjeff2:Leaderboard-wire-up-live-data-from-agent-registry-(replaces-mock-data)-#195

Conversation

@clintjeff2

Copy link
Copy Markdown
Contributor

Motivation

  • Replace the mock/jittered leaderboard data with real agent data from the registry so leaderboards reflect live agents and earned XP.
  • Use XP for the global ranking and task completions for per-district ranking so leaderboard metrics align with the XP and reputation systems.
  • Make the leaderboard update promptly for users and show an empty-state when no agents exist.

Description

  • Replace the BASE_AGENTS mock with a live call to getAgentRegistry() and enrich each agent with XP via getAgentXP() and task/reputation metrics via getReputation() in lib/leaderboard.ts, and remove the jitter() logic.
  • Add getAgentRegistry() export in lib/agent-registry.ts to expose the current in-memory registry.
  • Change sorting rules so global view sorts by XP (getAgentXP()), and district view sorts by task completions (from reputation metrics).
  • Update API caching for GET /api/leaderboard to return Cache-Control: public, max-age=30 to match the 30s client refresh cadence.
  • Adjust client polling in components/leaderboard/leaderboard-table.tsx (remove explicit { cache: "no-store" }) and add an empty-state message shown when no agents are registered.
  • Add regression tests in __tests__/api/leaderboard.test.ts covering XP ordering, district filtering/task sorting, empty-state behavior, and cache header.

Testing

  • Ran the leaderboard tests with npm test -- --run __tests__/api/leaderboard.test.ts, and all tests passed (3 passed).
  • The changes are covered by the new test file __tests__/api/leaderboard.test.ts which validates sorting, district filtering, empty response, and the cache header.

Closes #195

@sonarqubecloud

Copy link
Copy Markdown

@clintjeff2

Copy link
Copy Markdown
Contributor Author

@leocagli, review and merge.

@clintjeff2

Copy link
Copy Markdown
Contributor Author

@leocagli, please 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.

Leaderboard: wire up live data from agent registry (replaces mock data)

1 participant