SPlit up
Some checks failed
CI / Check (push) Failing after 1m58s
Build and publish Docker image / build-and-push (push) Failing after 1m5s

This commit is contained in:
Andras Schmelczer 2026-06-12 21:51:37 +01:00
parent cf39ad754e
commit f59d01227b
91 changed files with 10370 additions and 7562 deletions

View file

@ -340,16 +340,14 @@ pub fn compute_crime_by_year(
let points: Vec<CrimeYearPoint> = years
.iter()
.filter_map(|&year| {
let denom = fully_covered_rows
+ covered_counts.get(&year).copied().unwrap_or(0);
let denom = fully_covered_rows + covered_counts.get(&year).copied().unwrap_or(0);
if denom == 0 {
// No selected postcode has published data for this year.
return None;
}
Some(CrimeYearPoint {
year,
count: (sums.get(&year).copied().unwrap_or(0.0) / denom as f64)
as f32,
count: (sums.get(&year).copied().unwrap_or(0.0) / denom as f64) as f32,
})
})
.collect();
@ -365,6 +363,19 @@ pub fn compute_crime_by_year(
out
}
/// Latest year present anywhere in the by-year crime dataset. The client
/// compares each selection's last charted year against this to caption
/// force-level publication gaps (e.g. Greater Manchester ends mid-2019) as
/// stale data instead of letting old numbers read as current.
pub fn crime_latest_available_year(crime_by_year: &CrimeByYearData) -> Option<i32> {
crime_by_year
.years_by_type
.iter()
.flatten()
.copied()
.max()
}
pub fn compute_poi_feature_stats(
matching_rows: &[usize],
poi_metrics: &PostcodePoiMetrics,