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
Nonewhen the denominator is zero. - safe_
div_ f64 - Safe division for f64 numerator with i64 denominator.
Returns
Nonewhen 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).