MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / loadState

Function loadState

telemetry-worker/src/rollup.ts:1228–1247  ·  view source on GitHub ↗
(lane: Lane, env: Env)

Source from the content-addressed store, hash-verified

1226}
1227
1228async function loadState(lane: Lane, env: Env): Promise<RunState> {
1229 const rows = await lane.all<{ key: string; value: string }>(
1230 env.DB.prepare(
1231 `SELECT key, value FROM rollup_state
1232 WHERE key IN ('regular', 'windows', 'cohorts', 'checked', 'proof_scan', 'proof_records_from')`,
1233 ),
1234 );
1235 const byKey = new Map(rows.map((r) => [r.key, r.value]));
1236 let installedScan = byKey.get('proof_scan') ?? '';
1237 // The installed days were worked out with another beginning of the records
1238 // (USER_RECORDS_FROM was moved): the proof stands, and the days are worked out again.
1239 if (installedScan === 'done' && byKey.get('proof_records_from') !== userRecordsFrom(env)) installedScan = 'sweep';
1240 return {
1241 regular: stamps(byKey.get('regular')),
1242 windows: stamps(byKey.get('windows')),
1243 cohorts: byKey.get('cohorts') ?? '',
1244 checked: byKey.get('checked') ?? '',
1245 installedScan,
1246 };
1247}
1248
1249const STATE_UPSERT = `INSERT INTO rollup_state (key, value, updated_at) VALUES (?, ?, ?)
1250 ON CONFLICT (key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at`;

Callers 1

runScheduledFunction · 0.85

Calls 5

userRecordsFromFunction · 0.85
stampsFunction · 0.85
mapMethod · 0.80
prepareMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected