Frontend: Create a 'Keeper Statistics' page#745
Open
wheval wants to merge 1 commit into
Open
Conversation
- New route /keepers (frontend/app/keepers/page.tsx): public leaderboard table of top Keepers by tasks executed and bounties earned, backed by useKeeperStats (frontend/app/hooks/useKeeperStats.ts). - Indexer: added a keeperStats(limit: Int) GraphQL query, aggregating KeeperPaid events at the SQL layer (json_extract + GROUP BY on the existing events table) rather than pulling raw events into the frontend and summing them there - the requirement was 'fetch aggregate statistics from the indexer,' and no aggregate endpoint existed yet. Verified end-to-end against a live Apollo server + seeded sqlite db. While wiring this up, found the indexer's GraphQL layer (apollo-server-express, express, cors, jsonwebtoken - all required by existing code in api.js/resolvers.js) was never declared in package.json, so npm install + running the API has never actually worked. Added the missing dependencies so the new query (and the existing GraphQL API generally) is runnable. Closes SoroLabs#695 ## Test plan - Verified the new GraphQL resolver end-to-end: started a real Apollo server against a seeded sqlite db and confirmed keeperStats returns correctly aggregated, correctly-ordered results. - frontend: npx jest app/keepers/page.test.tsx - 4 tests pass (renders leaderboard, empty state, error state, loading state).
|
@wheval Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/keepers(frontend/app/keepers/page.tsx): a public leaderboard table of top Keepers by tasks executed and bounties earned, backed byuseKeeperStats(frontend/app/hooks/useKeeperStats.ts).keeperStats(limit: Int): [KeeperStat!]!GraphQL query, aggregatingKeeperPaidevents at the SQL layer (json_extract+GROUP BYon the existingeventstable) rather than pulling raw events into the frontend and summing them client-side - the issue asks to "fetch aggregate statistics from the indexer," and no aggregate endpoint existed yet, so building it was necessary to do that literally rather than working around it.bountiesEarnedXlmdivides the raw stroop amount by1e7, matching the convention the existing/keeper-metricspage already uses foravgFeePaidXlm.Found while wiring this up: the indexer's GraphQL layer (
apollo-server-express,express,cors,jsonwebtoken- all required by the existingapi.js/resolvers.js) was never declared inindexer/package.json.npm install && node index.jshas never actually been able to start the API server. Added the missing dependencies so the newkeeperStatsquery (and the GraphQL API generally) is actually runnable - verified end-to-end below.Closes #695
Test plan
keeperStatsreturns correctly aggregated, correctly-ordered results (2 keepers, correcttasksExecutedcounts andbountiesEarnedXlmsums).cd frontend && npx jest app/keepers/page.test.tsx- 4 tests pass (renders leaderboard ranked by tasks executed, empty state, error state, loading state).Note: the indexer's own test script (
npm test->node --test) currently fails to even run its existing Jest-style test file (describe/expectaren't valid undernode --test) and has one unrelated pre-existing failing test instaleTasks.test.js- both predate this change and are out of scope here, so I verified the new resolver manually instead of adding a test that would hit the same broken harness.