Properly format metrics on missing badname

This commit is contained in:
clerie 2024-07-21 11:56:55 +02:00
parent 72fc8fb588
commit 011fbdd2b7

View File

@ -143,7 +143,10 @@ async fn route_metrics(
let mut out = String::new(); let mut out = String::new();
for bad in trafficdata { for bad in trafficdata {
out.push_str(&format!("berlinerbaeder_occupation{{bad=\"{}\" badname=\"{}\"}} {}\n", bad.id, state.baedernames.get(&bad.id).unwrap_or(&String::new()), bad.counter.unwrap_or(-1))); match state.baedernames.get(&bad.id) {
Some(name) => out.push_str(&format!("berlinerbaeder_occupation{{bad=\"{}\", badname=\"{}\"}} {}\n", bad.id, name, bad.counter.unwrap_or(-1))),
None => out.push_str(&format!("berlinerbaeder_occupation{{bad=\"{}\"}} {}\n", bad.id, bad.counter.unwrap_or(-1))),
};
} }
return Ok(out); return Ok(out);