Skip to content

feat: pre-calculate leaderboard ranks and update user endpoints and UI#242

Open
Yashaswini-K-P wants to merge 2 commits into
codepvg:mainfrom
Yashaswini-K-P:feature/backend-leaderboard-ranks
Open

feat: pre-calculate leaderboard ranks and update user endpoints and UI#242
Yashaswini-K-P wants to merge 2 commits into
codepvg:mainfrom
Yashaswini-K-P:feature/backend-leaderboard-ranks

Conversation

@Yashaswini-K-P

Copy link
Copy Markdown
Contributor

Description

This PR restructures individual user profile files to store pre-calculated leaderboard rankings (overall, daily, weekly, and monthly) directly within the data repository sync loop.

This addresses a critical architectural constraint: because the API layer (fetchUserInfo) is stateless and lacks a database, it cannot compute relative user standings on the fly. By pre-calculating and saving these ranks during the automated sync process, the API can now cheaply and instantaneously serve up-to-date ranks and changes directly to the profile UI from a single file fetch.

Linked Issue

Fixes #195

Changes Made

  • Updated the backend sync script to pull user leaderboard standings across all historical intervals.
  • Appended a new leaderboardRanks metadata block directly onto individual user JSON profiles without breaking existing history streams.
  • Updated fetchUserInfo in the API service to parse the new object structure and inject actual rank metrics and trend trajectories into the payload.

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally
  • Tested on mobile viewport (if applicable)
  • No console errors introduced

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally by running npx prettier --write . before submitting
  • I am submitting my PR from a dedicated feature/* branch, not the main branch
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

Screenshots / Screen Recording

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

Formatting and Branching

  • Please confirm you have formatted your code locally using npx prettier --write ., or you can simply comment /format on this PR to have our bot do it for you!
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

@jagdish-15

Copy link
Copy Markdown
Collaborator

@Yashaswini-K-P

Could you please check and resolve these merge conflicts?

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.

feat: dynamically display rankings (daily, weekly, monthly, overall) on user profile

2 participants