Skip to main content

materialize_changes_bucketed

Function materialize_changes_bucketed 

pub fn materialize_changes_bucketed(
    db: &FactsDb,
    bucket: TimeBucket,
    use_lineage: bool,
) -> Result<()>
Expand description

Materialize a session-temporary changes_bucketed table that collapses commits within the same date_trunc(<bucket>, commit.date) window into a single logical “commit” per (bucket, path). Coupling-family analyses (coupling, clone-coupling indirectly, soc) query this table when opts.time_bucket.is_some() so commits landed across the same day/week/month count as one for pair-counting purposes.

The bucket key (a date string like 2024-01-15 for day-buckets) takes the place of rev. Within a bucket, loc_added and loc_deleted are summed; change_type collapses to MAX (string-alphabetical max — close enough since the bucketed-table is consumed only by analyses that care about pair counts, not type details).

Idempotent: CREATE OR REPLACE TEMPORARY TABLE. Call once per analysis run after the main ingest finishes. Cheap — single SQL pass over changes JOIN commits.

§Errors

Returns CodeLoreError::Analysis on any SQL error.