Sequential DB queries to minimize CPU load + optimized caching for leaderboards#229
Sequential DB queries to minimize CPU load + optimized caching for leaderboards#229sfreeman422 merged 3 commits intomasterfrom
Conversation
There was a problem hiding this comment.
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}anddashboard:leaderboards:{teamId}:{period}and merge on read. - Replace parallel
Promise.alldashboard 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.
Agent-Logs-Url: https://github.com/dev-chat/mocker/sessions/7a7d0ef5-dad1-434c-adaa-528e7a52fa0c Co-authored-by: sfreeman422 <16405652+sfreeman422@users.noreply.github.com>
|
@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>
Fixed in commit |
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)