SPlit up
This commit is contained in:
parent
cf39ad754e
commit
f59d01227b
91 changed files with 10370 additions and 7562 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue