Function build_sql
pub fn build_sql(opts: &Options, cm_src: &str) -> StringExpand description
The file_revs change source is resolved by routing the assembled SQL
through crate::analyses::lineage::rewrite, which rewrites every
FROM changes / JOIN changes to changes_lineage / changes_bucketed
when the corresponding flag is on. file_ai is deliberately EXEMPT: its
{ai_src} placeholder resolves to changes_lineage (canonical lineage) or
raw changes, never changes_bucketed — because ai_pct joins commits
on a real rev and changes_bucketed’s synthetic date-string rev would
never match, leaving ai_pct NULL under --time-bucket.
{cm_src} becomes complexity_metrics or complexity_metrics_grouped
(per analyses::grouped_complexity). {file_mi_cte} swaps the file_mi
CTE body between the entities-join (raw paths) form and the
pre-baked-from-grouped form — the entities join can’t be reused
post-grouping because entities.path is never rewritten by
apply_grouping, so the rolled-up mi must come straight from
complexity_metrics_grouped.mi.