Module query
Expand description
Shared prepare → query_map → collect → format!()-wrapped errors
boilerplate. Without this helper every analysis would copy-paste
the same 7-line pattern with only the SQL constant, params, and
mapper closure varying, and the error-message format would drift
across analyses.
Usage:
ⓘ
use crate::analyses::query::query_map_collect;
let rows: Vec<MyRow> = query_map_collect(
db, &sql, duckdb::params![opts.min_revs, row_limit], "my-analysis",
|r| Ok(MyRow { x: r.get(0)?, y: r.get(1)? }),
)?;Constants§
- HUMAN_
ALIASES_ CTE - CTE body: every
(raw_name, raw_email)alias row that is NOT bot-classified, alongside the canonical it resolves to.
Functions§
- clamped_
now_ anchor - SQL expression for the repository’s window anchor — the “now” that every trailing-window and time-decay term is measured against — clamped so a single future-dated commit cannot become “now” for the whole analysis.
- explain_
if_ requested - Emit the
DuckDBEXPLAIN plan forsql+paramsto stderr ifopts.explainis on. No-op otherwise. Shared so every analysis can add--explainsupport in one line instead of copying theif opts.explain { db.explain_sql(...)?; eprintln!(...); }block. - query_
map_ collect - Prepare +
query_map+ collect, with uniformCodeLoreError::Analysiserror context at each step.labelis interpolated into the error messages so debug output identifies which analysis failed. - wall_
clock_ utc_ literal - The current UTC instant as a
YYYY-MM-DD HH:MM:SSstring — the exact UTC-naive frame and format commit dates are stored in (facts::ingest::consumer’s timestamp formatter), for embedding as aDuckDBTIMESTAMPliteral.