Skip to content

fix: cache GitHub API responses for compare endpoint to avoid rate limiting#2872

Open
Tanisha-sharma7302 wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
Tanisha-sharma7302:fix/cache-github-api-2841
Open

fix: cache GitHub API responses for compare endpoint to avoid rate limiting#2872
Tanisha-sharma7302 wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
Tanisha-sharma7302:fix/cache-github-api-2841

Conversation

@Tanisha-sharma7302

Copy link
Copy Markdown

Fixes #2841

Problem

The /api/metrics/compare endpoint had a TTL reserved for it in metrics-cache.ts
(compare: 30 * 60) but never actually used it — instead it relied on a custom
Supabase-based cache keyed per viewer + target user + calendar day. This meant
every new (viewer, target, day) combination triggered 4-5 fresh GitHub API calls
with no short-term caching, contributing to rate-limit (403) responses under
repeated/rapid dashboard usage as described in the issue.

Fix

Switched the compare endpoint to use the existing withMetricsCache-style
Redis/memory caching system (cacheGet/cacheSet from metrics-cache.ts),
using the already-reserved 30-minute TTL — consistent with every other metrics
endpoint in the app. Also respects the existing ?refresh=true /
?bypassCache=true cache-bypass convention.

Testing

  • pnpm run type-check passes with no errors
  • Existing test suite (pnpm vitest run) unaffected

@github-actions

Copy link
Copy Markdown

Thanks for your first PR on DevTrack! 🎉

A maintainer will review it within 48 hours. While you wait:

  • Make sure CI is passing (type-check + lint)
  • Double-check the PR description is filled out and the issue is linked
  • Feel free to ask questions in Discussions if you need help

If you find DevTrack useful, a ⭐ star on the repo is always appreciated — it helps the project grow and attract more contributors!

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix labels Jun 27, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — 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:performance GSSoC type bonus: performance (+15 pts) labels Jun 27, 2026
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:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PERFORMANCE] GitHub API responses not cached server-side, causing repeated identical requests on every dashboard page load

1 participant