Skip to content

fix: stabilize guild monthly leaderboards#844

Open
ugcodrr wants to merge 3 commits into
mainfrom
fix/guild-monthly-leaderboards
Open

fix: stabilize guild monthly leaderboards#844
ugcodrr wants to merge 3 commits into
mainfrom
fix/guild-monthly-leaderboards

Conversation

@ugcodrr
Copy link
Copy Markdown
Member

@ugcodrr ugcodrr commented May 12, 2026

Summary

  • preserve cached per-day guild GEXP totals when recomputing rolling daily/weekly/monthly values
  • prevent monthly/scaled monthly GEXP from dropping when member history disappears from the current Hypixel guild member list
  • keep guild leaderboard rendering resilient when a stale leaderboard id maps to a missing or partial guild document
  • reuse the shared exp-history merge helper for member history so the cached/current GEXP merge avoids per-day object spreading and extra allocations

Root Cause

Guild monthly GEXP was recomputed only from the current Hypixel member list. If a member left, or if current member history omitted a day that was previously cached, that contribution disappeared from the recomputed 30-day aggregate and Redis leaderboard scores could be updated downward without an actual monthly reset.

The member-level cached/current history merge also rebuilt the accumulator object on every cached day. Reusing the same helper used by the guild-level preserved totals keeps the stabilization behavior intact while reducing temporary allocations during guild refreshes.

Testing

  • pnpm --filter api test:types
  • pnpm vitest --project api

@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
statsify Skipped Skipped May 30, 2026 10:03am

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR stabilizes guild GEXP leaderboard calculations by preserving cached guild history during refreshes and making guild leaderboard rows more resilient to stale ids.

Changes:

  • Adds an API Vitest config so in-source API tests can run.
  • Refactors exp-history conversion into a helper and preserves cached guild daily totals with max-per-day merging.
  • Makes guild leaderboard additional stats tolerate missing guild documents.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
apps/api/vitest.config.ts Adds Vitest configuration for the API app.
apps/api/src/guild/guild.service.ts Adds shared exp-history helpers, combines cached/current guild GEXP history, and tests the preservation behavior.
apps/api/src/guild/leaderboards/guild-leaderboard.service.ts Falls back safely when leaderboard ids point to missing guild documents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/api/src/guild/leaderboards/guild-leaderboard.service.ts
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants