Skip to content

Leaderboard Has No Privacy Option and No Response Caching #13

Description

@rishabhx29

Description

Two issues exist with the current Leaderboard:

  1. No privacy option: All users appear on the leaderboard with no way to opt out, even if they prefer their stats to remain private.
  2. 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

  • Add isPublic Boolean @default(true) to the User model in schema.prisma and run migration.
  • Filter isPublic: false users out of the leaderboard query.
  • Add a privacy toggle in user settings UI.
  • Add 60-second in-memory caching to the leaderboard endpoint.
  • Show the authenticated user's own rank below the leaderboard table even when outside the top N.

Acceptance Criteria

  • Users with isPublic: false are excluded from the leaderboard response.
  • Privacy toggle is accessible from user settings.
  • Leaderboard response is cached for 60 seconds.
  • Authenticated user always sees their own rank on the leaderboard page.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions