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

Function ledger

__tests__/telemetry-services.test.ts:364–376  ·  view source on GitHub ↗

Where each seeded usage count sits right now, and whether the day has been rolled up.

(day: string)

Source from the content-addressed store, hash-verified

362
363 /** Where each seeded usage count sits right now, and whether the day has been rolled up. */
364 function ledger(day: string) {
365 const folded = Number(one('SELECT coalesce(sum(count), 0) AS n FROM usage_daily WHERE day = ?', day)?.n);
366 const unfolded = Number(
367 one(
368 `SELECT coalesce(sum(json_extract(props, '$.count')), 0) AS n FROM events
369 WHERE day = ? AND event = 'usage_rollup'`,
370 day,
371 )?.n,
372 );
373 const rolledUsage = one(`SELECT count FROM daily_event_counts WHERE day = ? AND event = 'usage_rollup'`, day);
374 const rolledUp = one('SELECT machines FROM daily_machines WHERE day = ?', day) !== undefined;
375 return { folded, unfolded, rolledUsage: rolledUsage ? Number(rolledUsage.count) : null, rolledUp };
376 }
377
378 function expectConsistent(): void {
379 for (const day of MISSED) {

Callers 2

expectConsistentFunction · 0.85

Calls 2

NumberInterface · 0.85
oneFunction · 0.70

Tested by

no test coverage detected