aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2011-05-02 22:42:35 +0200
committerPetter Reinholdtsen <pere@hungry.com>2011-05-09 17:43:27 +0200
commit8546c2f5feabf345b78dd1b6bb688e8451ea01d0 (patch)
tree1912ee1d1a19596cc063711b13f83b84841214f6 /bin
parent81d8b8fc9d58d1093464588928dc95145b517d52 (diff)
Index by council ID not name, to handle two with the same name.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/showcouncilrates20
1 files changed, 11 insertions, 9 deletions
diff --git a/bin/showcouncilrates b/bin/showcouncilrates
index cdfc26ce3..9ae5c3e7b 100755
--- a/bin/showcouncilrates
+++ b/bin/showcouncilrates
@@ -48,24 +48,26 @@ my %adminsum;
my %adminfixed;
foreach my $row (@$stats){
if ($row->{council}) {
- my @council_names = map { $areas_info->{$_}->{name} } @{$row->{council}} ;
- for my $council (@council_names) {
- $adminsum{$council} += $row->{total};
- $adminfixed{$council} += $row->{fixed};
+ for my $councilid (@{$row->{council}}) {
+ $adminsum{$councilid} += $row->{total};
+ $adminfixed{$councilid} += $row->{fixed};
}
}
}
-foreach my $council (sort sort_councils keys %adminsum) {
- my $total = $adminsum{$council};
- my $fixed = $adminfixed{$council};
- printf("%5.1f %4d %s\n", 100 * $fixed / $total, $total, $council);
+foreach my $councilid (sort sort_councils keys %adminsum) {
+ my $council = $areas_info->{$councilid}->{name};
+ my $total = $adminsum{$councilid};
+ my $fixed = $adminfixed{$councilid};
+ printf("%5.1f %4d %s (%d)\n", 100 * $fixed / $total, $total,
+ $council, $councilid);
}
sub sort_councils {
my $retval = ($adminfixed{$b} / $adminsum{$b}) <=>
($adminfixed{$a} / $adminsum{$a});
$retval = $adminsum{$b} <=> $adminsum{$a} unless $retval;
- $retval = strcoll($a, $b) unless $retval;
+ $retval = strcoll($areas_info->{$a}->{name},
+ $areas_info->{$b}->{name}) unless $retval;
return $retval;
}