Skip to content

🐛 Fix monthly leaderboard and sorting users#1555

Open
jernejk wants to merge 3 commits into
mainfrom
codex/leaderboard-monthly-last-30-days
Open

🐛 Fix monthly leaderboard and sorting users#1555
jernejk wants to merge 3 commits into
mainfrom
codex/leaderboard-monthly-last-30-days

Conversation

@jernejk

@jernejk jernejk commented May 2, 2026

Copy link
Copy Markdown
Member
  1. What triggered this change? (PBI link, Email Subject, conversation + reason, etc)

Boss reported that the Monthly mobile leaderboard was effectively empty early in the month. The API treated ThisMonth as calendar-month-to-date, so on May 2 it only looked at roughly 2 days instead of the expected recent month of activity.

  1. What was changed?

Changed LeaderboardService so PointsThisMonth uses a rolling 30-day UTC window. PointsThisYear is still calendar-year based, and the existing weekly rolling 7-day behavior is unchanged.

Also stabilized leaderboard sorting across the API paths. Period leaderboards now sort by selected period points, then name. All-time ranking is also stable by total points, then name. This avoids tied scores falling back to arbitrary cached/DB result order while keeping the query simple.

Validation:

  • MSBuildEnableWorkloadResolver=false dotnet test tests/Application.UnitTests/Application.UnitTests.csproj --no-restore passed 61/61
  • MSBuildEnableWorkloadResolver=false dotnet build src/WebAPI/WebAPI.csproj succeeded

The environment is missing the pinned .NET workload set 10.0.103, so the workload resolver had to be disabled for the local run.

  1. Did you do pair or mob programming?

Worked with Codex.

Copilot AI review requested due to automatic review settings May 2, 2026 13:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes the “Monthly” leaderboard calculation so it reflects recent activity (rolling 30-day window) instead of calendar month-to-date, preventing the leaderboard appearing effectively empty early in a month.

Changes:

  • Update LeaderboardService to compute PointsThisMonth using a rolling last-30-days UTC window.
  • Keep existing weekly rolling-window behavior and yearly calendar-year behavior unchanged.
  • Add a unit test validating the January boundary case (late-December counts for Monthly but not Yearly).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Application/Leaderboard/LeaderboardService.cs Changes monthly points aggregation from calendar-month filter to a 30-day rolling UTC range.
tests/Application.UnitTests/Leaderboard/LeaderboardServiceTests.cs Adds coverage for the rolling-month behavior across a year boundary while preserving yearly semantics.

@jernejk jernejk changed the title [codex] Fix monthly leaderboard rolling window 🐛 Fix monthly leaderboard rolling window May 4, 2026
@jernejk jernejk changed the title 🐛 Fix monthly leaderboard rolling window 🐛 Fix monthly leaderboard and sorting users May 4, 2026

@jeoffreyfischer jeoffreyfischer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@jeoffreyfischer jeoffreyfischer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

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.

3 participants