fix(metrics): include timezone in cache keys for timezone-sensitive endpoints#2781
fix(metrics): include timezone in cache keys for timezone-sensitive endpoints#27810xPyxis wants to merge 1 commit into
Conversation
|
Thanks for your first PR on DevTrack! 🎉 A maintainer will review it within 48 hours. While you wait:
If you find DevTrack useful, a ⭐ star on the repo is always appreciated — it helps the project grow and attract more contributors! |
GSSoC Label Checklist 🏷️@Umbrella-io — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
| timeZone = "UTC", | ||
| ): Promise<Set<string>> { | ||
| const key = metricsCacheKey(cacheContext.userId, "streak", { githubLogin }); | ||
| const key = metricsCacheKey(cacheContext.userId, "streak", { |
There was a problem hiding this comment.
Please add a WHY comment here.
|
Good catch on the timezone cache key bug — this is a legitimate fix. Two things before merge:
Fix the indentation and this is good to go. |
Summary
Fixes a timezone-related caching bug in metrics endpoints.
Closes #2716
Type of Change
What Changed
timezoneto the cache key parameters insrc/app/api/metrics/contributions/route.tstimeZoneto the cache key parameters insrc/app/api/metrics/streak/route.tstimeZoneto the cache key parameters insrc/app/api/metrics/consistency-score/route.tsHow to Test
Asia/Kolkata) and load Contributions, Streak, or Consistency Score metrics.America/New_York).Expected result:
Metrics should be recalculated or fetched from a timezone-specific cache entry instead of reusing data generated for a different timezone.
Checklist
console.log, debug code, or commented-out blocksnpm run lintpasses locallynpm run type-check)Additional Context
The cache keys previously omitted timezone information, causing timezone-sensitive metrics to be reused across different timezone settings. This change ensures cache entries are properly scoped per timezone.