pub fn value(m: &EconomicsMetric) -> StringExpand description
A metric’s value as the report spells it: amount in the metric’s unit, and an
absent value the words not measured, so that an unmeasured metric never reads as a
change of zero.
use majordomus_cli::economics::{model::EconomicsMetric, report};
let m: EconomicsMetric = serde_json::from_value(serde_json::json!({
"id": "effective_token_reduction", "title": "Effective token reduction",
"class": "derived", "unit": "ratio", "formula": "1 - treatment / control",
"value": 0.2, "status": "preliminary", "n": 3, "suite": "pilot"
}))
.unwrap();
assert_eq!(report::value(&m), "+20.0%");
assert_eq!(report::value(&EconomicsMetric { value: None, ..m }), "not measured");