test(cache): integration coverage + CHANGELOG entry for server cache

Three integration tests against the real Postgres container pin the
v1.4.34 IW-G contract:

  1. Ten concurrent /api/analytics reads against a cold cache fan into
     a single builder call (misses === 1; remaining 9 split between
     stampede joiners and warm-cache hits, with no second miss).
  2. Priming analytics then writing a measurement evicts the cache —
     the next read misses again and the response reflects the new row.
  3. Compliance buckets re-read after an intake POST flush the cache
     and surface the new taken-count.

Drops the unused _request parameter from buildAnalyticsResponse() so
the analytics route lints clean. CHANGELOG carries one Added line per
the marathon's user-facing voice rules.
This commit is contained in:
Marc-André Bombeck committed 2026-05-16 21:11:37 +02:00
1 parent 757387ca83
commit bcdab48e96
3 files changed
+287 -5

No files matched your search

+2 -5
View File
@@ -91,7 +91,7 @@ export const GET = apiHandler(async (request?: Request) => {
const body = await cached(
caches.analytics as ServerCache<Awaited<ReturnType<typeof buildAnalyticsResponse>>>,
`${user.id}|default`,
() => buildAnalyticsResponse(user, request),
() => buildAnalyticsResponse(user),
annotate,
);
@@ -116,10 +116,7 @@ type AuthedUser = Awaited<ReturnType<typeof requireAuth>>["user"];
* matches the v1.4.33 snapshot LRU's `buildCoachSnapshot` →
* `buildCoachSnapshotImpl` shape.
*/
async function buildAnalyticsResponse(
user: AuthedUser,
_request: Request | undefined,
) {
async function buildAnalyticsResponse(user: AuthedUser) {
// v1.4.25 W7b — every day-bucket call inside this route now honours
// the user's display timezone. The legacy `berlinDayKey()` import
// remains for sleep-stage and correlation paths that share their