pub fn totals(run: &EconomicsRun) -> Option<EconomicsUsage>Expand description
A run’s totals: the sum of its sessions’. None when any session reported nothing,
because a partial sum would understate the run.
use majordomus_cli::economics::model::{EconomicsRun, EconomicsSession};
use majordomus_cli::economics::usage::{anthropic_request, totals};
// two sessions, of (input, output) tokens (100, 20) and (50, 10)
run.sessions = vec![session(100, 20), session(50, 10)];
assert_eq!(totals(&run).map(|t| (t.total, t.requests)), Some((180, 2)));
run.sessions[1].requests.clear();
assert_eq!(totals(&run), None, "one silent session voids the sum rather than shrinking it");