mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
refactor(cache): keep the closed-block key helpers in a leaf module
Readers that tag a cell as a closed block no longer import the invalidation module, which several tests replace wholesale. The cache route test counts the slice's pre-fold cell apart from the route's two cells, and the provenance test reads the shared pick's ORDER BY over its grouped rows.
This commit is contained in:
1 parent
4c86b68363
commit
83661319d2
7 files changed
+48
-36
No files matched your search
@@ -117,8 +117,21 @@ function countBuildsPerKey(cache: {
|
||||
return builds;
|
||||
}
|
||||
|
||||
/**
|
||||
* The slice's pre-fold remainder is a cell of its own in the same bucket (a
|
||||
* closed block, `pre-fold-remainder.ts`), built when the slice takes the
|
||||
* rollup path; it is counted apart from the route's two cells.
|
||||
*/
|
||||
function preFoldBuildsOf(builds: Map<string, number>, userId: string) {
|
||||
return [...builds.entries()]
|
||||
.filter(([k]) => k.startsWith(`${userId}|pre-fold-remainder|`))
|
||||
.reduce((n, [, c]) => n + c, 0);
|
||||
}
|
||||
|
||||
function buildsOf(builds: Map<string, number>, userId: string) {
|
||||
const entries = [...builds.entries()].filter(([k]) => k.startsWith(userId));
|
||||
const entries = [...builds.entries()].filter(
|
||||
([k]) => k.startsWith(userId) && !k.includes("|pre-fold-remainder|"),
|
||||
);
|
||||
return {
|
||||
defaultBody: entries
|
||||
.filter(([k]) => k.startsWith(`${userId}|default|`))
|
||||
@@ -230,7 +243,9 @@ describe("v1.4.34 IW-G — server-cache route integration", () => {
|
||||
summaries: 2,
|
||||
keys: 2,
|
||||
});
|
||||
expect(caches.analytics.stats().misses).toBe(4);
|
||||
expect(caches.analytics.stats().misses).toBe(
|
||||
4 + preFoldBuildsOf(builds, user.id),
|
||||
);
|
||||
|
||||
// Sanity: the body reflects the new write.
|
||||
const body = (await third.json()) as {
|
||||
|
||||
Reference in new issue
Block a user