Description
Two issues exist with the current Leaderboard:
- No privacy option: All users appear on the leaderboard with no way to opt out, even if they prefer their stats to remain private.
- No caching: Every leaderboard page load executes a full database sort on the
User collection. At scale, this becomes expensive with no performance benefit since leaderboard data does not need real-time precision.
Requirements
- Add an
isPublic Boolean @default(true) field to the User model in schema.prisma.
- Filter out users with
isPublic: false from the leaderboard query.
- Add a privacy toggle in user settings.
- Cache the leaderboard response for 60 seconds (in-memory or Redis).
- Always show the authenticated user's own rank below the list, regardless of their
isPublic setting.
Expected Behavior
User with isPublic: false — Does not appear in the public leaderboard. Can still see their own rank privately on the Dashboard and Leaderboard page.
Leaderboard API — Response is cached for 60 seconds; stale data is served between refreshes to reduce DB load.
Tasks
Acceptance Criteria
Description
Two issues exist with the current Leaderboard:
Usercollection. At scale, this becomes expensive with no performance benefit since leaderboard data does not need real-time precision.Requirements
isPublic Boolean @default(true)field to theUsermodel inschema.prisma.isPublic: falsefrom the leaderboard query.isPublicsetting.Expected Behavior
User with
isPublic: false— Does not appear in the public leaderboard. Can still see their own rank privately on the Dashboard and Leaderboard page.Leaderboard API — Response is cached for 60 seconds; stale data is served between refreshes to reduce DB load.
Tasks
isPublic Boolean @default(true)to theUsermodel inschema.prismaand run migration.isPublic: falseusers out of the leaderboard query.Acceptance Criteria
isPublic: falseare excluded from the leaderboard response.