Skip to content

fix: support combined account filter in weekly summary endpoint (#2421)#2455

Open
shauryavardhan1307 wants to merge 10 commits into
Umbrella-io:mainfrom
shauryavardhan1307:fix/weekly-summary-combined-2421
Open

fix: support combined account filter in weekly summary endpoint (#2421)#2455
shauryavardhan1307 wants to merge 10 commits into
Umbrella-io:mainfrom
shauryavardhan1307:fix/weekly-summary-combined-2421

Conversation

@shauryavardhan1307

Copy link
Copy Markdown
Contributor

Summary

This PR resolves a 404 Account not found error returned by /api/metrics/weekly-summary?accountId=combined by implementing support for the "combined" account filter. The endpoint now aggregates commits, PRs, active days, streaks, and top repository statistics across all of the user's linked GitHub/external accounts.

Closes #2421


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • Weekly Summary Route Refactoring (route.ts):
    • Added support for accountId === "combined".
    • Extracted single-account weekly summary logic into a private helper function fetchWeeklySummaryForAccount.
    • Fetches weekly summaries for all linked accounts concurrently using Promise.allSettled.
    • Merges commits, PRs, and active days (capping the weekly active days at 7).
    • Uses the maximum current streak across accounts as a safe fallback.
    • Resolves the top repository by selecting the hottest repo from the account with the most commits.
  • Unit Testing (weekly-summary-combined.test.ts):
    • Added a new unit test suite validating the concurrent fetching, merge logic, active days capping, and fallback rules.

How to Test

  1. Check out the branch fix/weekly-summary-combined-2421.
  2. Run the new unit test suite to verify the endpoint's behavior with multiple accounts:
    npx vitest run test/weekly-summary-combined.test.ts
  3. Load the dashboard in a browser using an account with multiple linked profiles, select the Combined view, and verify that the Weekly Summary widget successfully loads and displays aggregated stats instead of showing an error.

Expected result:

  • The unit test passes successfully.
  • The Weekly Summary widget fetches and aggregates statistics correctly for the combined account filter without returning a 404.

Screenshots / Recordings

No UI changes; this PR only updates backend route logic.


Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • Added or updated tests where applicable

Accessibility (UI changes only)

Not applicable (Backend-only change).


Additional Context

  • The combined metrics cache uses a specific key (metrics:user-id:weekly-summary:{"accountId":"combined"}) to prevent collisions with individual account caches, while still utilizing cached data for each sub-account fetch.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:testing GSSoC type bonus: tests (+10 pts) labels Jun 15, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Umbrella-io — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@github-actions github-actions Bot added type:feature GSSoC type bonus: new feature type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) labels Jun 15, 2026
@shauryavardhan1307 shauryavardhan1307 force-pushed the fix/weekly-summary-combined-2421 branch from fe042e0 to cf35165 Compare June 15, 2026 03:48
@shauryavardhan1307

Copy link
Copy Markdown
Contributor Author

Hi @Priyanshu-byte-coder,I have updated the PR to resolve the type-check and build failures:

  • TypeScript Fix: Added non-null assertion checks to session variables in src/app/api/metrics/weekly-summary/route.ts to satisfy strict typing for the getAllAccounts helper. Local type check (npm run type-check) is now passing successfully.
    Regarding the failing Playwright Smoke Tests and Visual Regression CI checks, these are pre-existing issues on the main branch. Since this PR is purely backend-focused (adding support for the combined filter on the weekly summary API route) and introduces no changes to UI components or layouts, it has no impact on these visual and UI regression suites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Broken "combined" Filter on /api/metrics/weekly-summary

1 participant