Commit 7a22134
authored
fix(cache): include both from and to dates in contribution cache key (JhaSourav07#1668)
## Description
The `cacheKey` function for contributions only used the year portion of
`options.from`, completely ignoring `options.to`. This meant requests
with different date ranges but the same start year produced identical
cache keys, causing data poisoning across queries.
Fixes JhaSourav07#1367:
- Cache collision: `?from=2024-01-01&to=2024-06-30` and
`?from=2024-01-01&to=2024-12-31` shared key `contributions:user:2024`
- Stale data: the first fetch's response was served to all subsequent
queries regardless of their date range
- Hard to detect: no error surfaced, just silently wrong data for
half-year projections
## Pillar
- [ ] Pillar 1 - New Theme Design
- [ ] Pillar 2 - Geometric SVG Improvement
- [ ] Pillar 3 - Timezone Logic Optimization
- [x] Other (Bug fix, refactoring, docs)
## Checklist before requesting a review:
- [x] I have read the CONTRIBUTING.md file.
- [x] I have tested these changes locally.
- [x] I have run npm run format and npm run lint locally and resolved
all errors.
- [x] My commits follow the Conventional Commits format.2 files changed
Lines changed: 31 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1106 | 1106 | | |
1107 | 1107 | | |
1108 | 1108 | | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
1109 | 1121 | | |
1110 | 1122 | | |
1111 | 1123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
215 | 227 | | |
216 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
217 | 234 | | |
218 | 235 | | |
219 | 236 | | |
| |||
272 | 289 | | |
273 | 290 | | |
274 | 291 | | |
275 | | - | |
| 292 | + | |
276 | 293 | | |
277 | 294 | | |
278 | 295 | | |
| |||
0 commit comments