added a stat for how many people put only 1 preference above the line
This commit is contained in:
parent
cb02be7d8e
commit
9d8d601c6a
|
|
@ -28,6 +28,10 @@ impl Ballot {
|
||||||
stats.both += 1;
|
stats.both += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if votes_candidate.len() == 0 && votes_party.len() == 1 {
|
||||||
|
stats.party_single += 1;
|
||||||
|
}
|
||||||
|
|
||||||
if votes_candidate.len() >= CANDIDATE_MIN.min(header.candidates.len()) {
|
if votes_candidate.len() >= CANDIDATE_MIN.min(header.candidates.len()) {
|
||||||
votes_candidate.sort_by(|a, b| i32::cmp(&a.0, &b.0));
|
votes_candidate.sort_by(|a, b| i32::cmp(&a.0, &b.0));
|
||||||
votes = votes_candidate.into_iter().map(|(_,id)| id).collect_vec();
|
votes = votes_candidate.into_iter().map(|(_,id)| id).collect_vec();
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ fn main() {
|
||||||
eprintln!("Ballots:");
|
eprintln!("Ballots:");
|
||||||
eprintln!(" Total: {}", counter.stats.total);
|
eprintln!(" Total: {}", counter.stats.total);
|
||||||
eprintln!(" Above: {}, {}", counter.stats.party, Percent(counter.stats.party.into(), counter.stats.total.into()));
|
eprintln!(" Above: {}, {}", counter.stats.party, Percent(counter.stats.party.into(), counter.stats.total.into()));
|
||||||
|
eprintln!(" 1 Preference: {}, {}", counter.stats.party_single, Percent(counter.stats.party_single.into(), counter.stats.total.into()));
|
||||||
eprintln!(" Below: {}, {}", counter.stats.candidate, Percent(counter.stats.candidate.into(), counter.stats.total.into()));
|
eprintln!(" Below: {}, {}", counter.stats.candidate, Percent(counter.stats.candidate.into(), counter.stats.total.into()));
|
||||||
eprintln!(" Both: {}, {}", counter.stats.both, Percent(counter.stats.both.into(), counter.stats.total.into()));
|
eprintln!(" Both: {}, {}", counter.stats.both, Percent(counter.stats.both.into(), counter.stats.total.into()));
|
||||||
eprintln!("Quota: {}, {}", counter.get_quota(), Percent(counter.get_quota(), total));
|
eprintln!("Quota: {}, {}", counter.get_quota(), Percent(counter.get_quota(), total));
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ pub struct Stats {
|
||||||
pub total: u32,
|
pub total: u32,
|
||||||
pub candidate: u32,
|
pub candidate: u32,
|
||||||
pub party: u32,
|
pub party: u32,
|
||||||
|
pub party_single: u32,
|
||||||
pub both: u32,
|
pub both: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -14,6 +15,7 @@ impl Stats {
|
||||||
Self {
|
Self {
|
||||||
total: 0,
|
total: 0,
|
||||||
party: 0,
|
party: 0,
|
||||||
|
party_single: 0,
|
||||||
candidate: 0,
|
candidate: 0,
|
||||||
both: 0,
|
both: 0,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue