Skip to main content

Module derive

Module derive 

Source
Expand description

Derived metric computation for analytics buckets.

All division operations are safe against zero denominators and produce None (rendered as JSON null) rather than NaN / Infinity.

Functionsยง

compute_derived
Compute all derived metrics from a UsageBucket.
safe_div
Safe division returning None when the denominator is zero.
safe_div_f64
Safe division for f64 numerator with i64 denominator. Returns None when the denominator is zero.
safe_pct
Percentage safe against zero denominator. Returns 0.0 when denominator is zero. Result is rounded to 2 decimal places (matching the original CLI rounding: (pct * 100.0).round() / 100.0).