SPlit up
This commit is contained in:
parent
cf39ad754e
commit
f59d01227b
91 changed files with 10370 additions and 7562 deletions
|
|
@ -780,31 +780,28 @@ pub async fn get_export(
|
|||
// groups themselves; postcodes within a group are sorted alphabetically.
|
||||
// Each group carries a rolled-up summary aggregate for its header row.
|
||||
let outcode_groups: Vec<OutcodeGroup> = {
|
||||
let mut order: Vec<String> = Vec::new();
|
||||
let mut by_outcode: FxHashMap<String, OutcodeGroup> = FxHashMap::default();
|
||||
let mut groups: Vec<OutcodeGroup> = Vec::new();
|
||||
let mut idx_by_outcode: FxHashMap<String, usize> = FxHashMap::default();
|
||||
for (i, (pc_idx, agg)) in postcode_aggs.iter().enumerate() {
|
||||
let outcode = outcode_of(&postcode_data.postcodes[*pc_idx]).to_string();
|
||||
let group = by_outcode.entry(outcode.clone()).or_insert_with(|| {
|
||||
order.push(outcode.clone());
|
||||
OutcodeGroup {
|
||||
outcode: outcode.clone(),
|
||||
let idx = *idx_by_outcode.entry(outcode.clone()).or_insert_with(|| {
|
||||
groups.push(OutcodeGroup {
|
||||
outcode,
|
||||
members: Vec::new(),
|
||||
summary: PostcodeExportAgg::new(total_export_features),
|
||||
}
|
||||
});
|
||||
groups.len() - 1
|
||||
});
|
||||
group.members.push(i);
|
||||
group.summary.merge_from(agg);
|
||||
groups[idx].members.push(i);
|
||||
groups[idx].summary.merge_from(agg);
|
||||
}
|
||||
for group in by_outcode.values_mut() {
|
||||
for group in &mut groups {
|
||||
group.members.sort_by(|&a, &b| {
|
||||
postcode_data.postcodes[postcode_aggs[a].0]
|
||||
.cmp(&postcode_data.postcodes[postcode_aggs[b].0])
|
||||
});
|
||||
}
|
||||
order
|
||||
.into_iter()
|
||||
.map(|outcode| by_outcode.remove(&outcode).unwrap())
|
||||
.collect()
|
||||
groups
|
||||
};
|
||||
|
||||
// Build Excel workbook with two sheets
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue