Skip to content

Sequential DB queries to minimize CPU load + optimized caching for leaderboards#229

Merged
sfreeman422 merged 3 commits intomasterfrom
fix/performance-sequential
Mar 30, 2026
Merged

Sequential DB queries to minimize CPU load + optimized caching for leaderboards#229
sfreeman422 merged 3 commits intomasterfrom
fix/performance-sequential

Conversation

@sfreeman422
Copy link
Copy Markdown
Collaborator

@sfreeman422 sfreeman422 commented Mar 30, 2026

  • Fix linting errors: remove if (!userData) / if (!leaderboards) null guards that ESLint flagged as @typescript-eslint/no-unnecessary-condition — TypeScript's control flow analysis already narrows both to non-null after the try-catch (catch always rethrows, so reaching the spread means the try succeeded)

Copilot AI review requested due to automatic review settings March 30, 2026 21:11
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 refactors the backend dashboard data fetch path to reduce concurrent DB query load and to improve cache reuse by splitting dashboard caching into per-user and per-team (leaderboards) entries.

Changes:

  • Split Redis caching into dashboard:user:{teamId}:{userId}:{period} and dashboard:leaderboards:{teamId}:{period} and merge on read.
  • Replace parallel Promise.all dashboard queries with sequential queries to reduce concurrent DB pressure (including sequential leaderboard queries).
  • Extend Jest tests to validate new cache keys and merged split-cache behavior.

Reviewed changes

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

File Description
packages/backend/src/dashboard/dashboard.persistence.service.ts Splits cache keys/values and makes dashboard + leaderboard DB queries sequential.
packages/backend/src/dashboard/dashboard.persistence.service.spec.ts Updates cache key assertions and adds coverage for merged split-cache reads without DB queries.

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

@sfreeman422
Copy link
Copy Markdown
Collaborator Author

@copilot fix linting errors

…sary-condition

Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/cdabef6c-a50c-4a38-96d9-c81990063ec0

Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI commented Mar 30, 2026

@copilot fix linting errors

Fixed in commit 2939b49. The null guards I added were flagged by @typescript-eslint/no-unnecessary-condition as "value is always falsy" — TypeScript's control flow analysis already narrows both userData and leaderboards to non-null after the try-catch block (since the catch always rethrows, reaching the spread guarantees the try succeeded and both were assigned). Removed the guards; the spread is already type-safe.

@sfreeman422 sfreeman422 merged commit 6f6450c into master Mar 30, 2026
10 checks passed
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