diigo-cache: fill job — a button that grabs every page (goal 1e)

POST /_fill (cache id in the body; target private|public; action
start|stop) starts or stops a background walk of every diigo page into
the cache. DO alarms advance it pagesPerStep pages per step (default
20), a second apart; progress (FillStatus) is stored in the DO after
each page, so it survives eviction. Cached pages are skipped; starting
while running rejoins the job; a stop mid-step wins; a failure is
recorded with its reason and logged once. The created page gets fill
buttons; the public page shows "filling: n of m pages".

Fill state is new, additive DO storage (fill, fillStep): no existing
state changes meaning.

The 13 fill specs are unskipped and green, plus one: a fill makes one
diigo call per page fetched.

Generated-by: Claude Opus 5.5
This commit is contained in:
dckc committed 2026-10-07 04:25:38 -05:00
1 parent 530942f5d9
commit 31ded9735b
4 files changed
+182 -15

No files matched your search

+8 -5
View File
@@ -4,9 +4,9 @@ import { describe, expect, it, vi } from "vitest";
import worker from "../src/index.js";
import { toWebkey } from "../src/webkeys.js";
// goal 1e (capsite checklist): a job that grabs every page. The design as
// tests; unskip as it lands. Fake accounts: tests/fake-webapp.js
// ("fake-webapp-id": 30 items = 2 pages of 24, every 3rd private).
// goal 1e (capsite checklist): a job that grabs every page. Fake
// accounts: tests/fake-webapp.js ("fake-webapp-id": 30 items = 2 pages
// of 24, every 3rd private).
type TestEnv = {
CACHE_DO: DurableObjectNamespace<import("../src/cache.js").DiigoCache>;
@@ -29,13 +29,16 @@ const drain = async (stub: DurableObjectStub, max = 20) => {
return ran;
};
describe.skip("fill job (goal 1e)", () => {
describe("fill job (goal 1e)", () => {
it("fills every page; afterwards every page is a hit with no webapp call", async () => {
const stub = await wired();
const atStart = await testEnv.WEBAPP.calls();
expect((await stub.startFill()).state).toBe("running");
await drain(stub);
const status = await stub.fillStatus();
expect(status).toMatchObject({ state: "done", pages: 2, fetched: 2 });
// one diigo call per page fetched (no extra page-1 fetch per miss)
expect((await testEnv.WEBAPP.calls()) - atStart).toBe(2);
const before = await testEnv.WEBAPP.calls();
for (const n of [1, 2]) expect((await stub.page(n, 24)).cached).toBe(true);
@@ -114,7 +117,7 @@ describe.skip("fill job (goal 1e)", () => {
});
});
describe.skip("fill routes (goal 1e)", () => {
describe("fill routes (goal 1e)", () => {
const call = (path: string, init?: RequestInit) =>
worker.fetch(new Request(`https://diigo-cache.test${path}`, init), env as never);
const post = (body: Record<string, string>) =>