Skip to main content

generate

Function generate 

Source
pub fn generate(
    session: &SessionRow,
    events: &[StoredEvent],
    ended_at: DateTime<Utc>,
) -> WrapReport
Expand description

Pure wrap computation. No clock, no disk.

ended_at is the caller’s snapshot of “when did the session end?” — in production it is Utc::now() at the moment app.run() returns. Keeping it an argument makes this function deterministic: tests pin a specific end timestamp and get a reproducible report.

Events outside the session’s [started_at, ended_at] window are included as-is — the session sink only writes events belonging to the current session row, so a stray out-of-window event would already indicate a store bug, and silently filtering it here would mask the bug.