app/db/phages.ts
24 lines and 4 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| listPhages | 16 to 19 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| <anonymous:18> | 18 to 18 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| listPhageRows | 22 to 28 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| <anonymous:27> | 27 to 27 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
Imports
It imports app/db/client.ts, app/db/schema.ts, app/lib/phages/compile.mjs. Imported by app/kb/procedures/proof.server.ts, app/lib/carrel/phage-handler.server.ts, app/lib/operator/api.server.ts, app/lib/operator/sync-tools.server.ts, app/lib/pages/save.server.ts, app/lib/phages/save.server.ts, app/routes/lab.kind.tsx, app/routes/lab.tsx, app/routes/lab[.md].ts, app/routes/phages.tsx.
Source
// The phages table: read by the page compile that draws the table on /research/phages (a page save and
// sync_pages read it here) and by the operator API. Written only by writePhageRow in
// app/lib/phages/save.server.ts and by sync:content, from a compile (app/lib/phages/compile.mjs).
import { asc } from "drizzle-orm";
import { sortPhages, type Phage } from "~/lib/phages/compile.mjs";
import { getDb } from "./client";
import { phages } from "./schema";
/**
* Every phage, in the page's order. An empty table is a fault, never an empty table on the page: the page is
* compiled from these rows, and a table the sync has not written yet must not quietly compile a page with no
* phages on it (expandPhagePage refuses an empty set and names the sync).
*/
export async function listPhages(env: Env): Promise<Phage[]> {
const rows = await getDb(env).select({ record: phages.record }).from(phages);
return sortPhages(rows.map((row) => JSON.parse(row.record) as Phage));
}
/** For list_phages and Carrel's list: every row, with when D1 last wrote it. */
export async function listPhageRows(env: Env) {
const rows = await getDb(env)
.select({ slug: phages.slug, name: phages.name, year: phages.year, record: phages.record, syncedAt: phages.syncedAt })
.from(phages)
.orderBy(asc(phages.year), asc(phages.name));
return rows.map(({ record, ...row }) => ({ ...row, phage: JSON.parse(record) as Phage }));
}