rigs.ts
@file Every statement this Worker runs against D1.
Overview
@file Every statement this Worker runs against D1. Nothing outside this file writes SQL, and nothing in this file builds SQL by concatenation. Each query is a constant with bound parameters, so a value arriving from a Discord field cannot become syntax.
used by context.ts forget.ts help-me.ts ihave.ts matrix.ts test-request.ts who-has.ts db.ts matrix.ts render.ts roleConnection.ts
API
Fexport async function upsertRig(db: D1Database | undefined, row: Omit<RigRow, "updated_at" | "probe_serial"> & { probe_serial?: string | null }): Promise<void>
Record what one contributor has for one board. Re-running it for the same board replaces that entry rather than accumulating rows.
modalHandler · calls need, runFexport async function forgetRig(db: D1Database | undefined, userId: string, board?: string): Promise<number>
Hard delete. board omitted deletes every board for that user. Returns
how many rows went, so the confirmation can be specific.
handler · calls need, runFexport async function entriesForUser(db: D1Database | undefined, userId: string): Promise<RigRow[]>
Every board one person has registered.
computeRegistryMetadata, handler, onModalSubmit · calls need, runFexport async function whoHas(db: D1Database | undefined, filter: { board?: string; iosVersion?: string }): Promise<RigRow[]>
Owners matching board and/or iOS version, most-recently-updated first. At least one filter is required by the caller (src/commands/who-has.ts); this function itself just runs whichever WHERE clause the filters imply.
handler, handler · calls need, runFexport async function matrixCounts(db: D1Database | undefined): Promise<MatrixCount[]>
Owner counts for every (board, ios_version) pair that has at least one owner. A pair absent from the result has zero owners — src/matrix.ts fills that in as the "nobody owns this" glyph rather than omitting the cell, since an empty cell is the entire point of the matrix.
handler · calls need, runFexport async function countForUser(db: D1Database | undefined, userId: string): Promise<number>
Used by tests to prove /forget leaves no row, and by nothing else.
need, runUndocumented (3)
RegistryUnavailable.constructor, need, run