mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-11-25 04:18 am

[dw-free] Business statistics

[commit: http://hg.dwscoalition.org/dw-free/rev/f1b881e72e8d]

http://bugs.dwscoalition.org/show_bug.cgi?id=124

Fix double counting of accounts by type in output.

Patch by [personal profile] afuna.

Files modified:
  • cgi-bin/DW/StatData/AccountsByType.pm
--------------------------------------------------------------------------------
diff -r 13b9b8990773 -r f1b881e72e8d cgi-bin/DW/StatData/AccountsByType.pm
--- a/cgi-bin/DW/StatData/AccountsByType.pm	Wed Nov 25 04:06:39 2009 +0000
+++ b/cgi-bin/DW/StatData/AccountsByType.pm	Wed Nov 25 04:18:51 2009 +0000
@@ -66,10 +66,13 @@ sub collect {
 =cut
 
 sub data {
-    my $self = shift;
-    my $data = $self->{data};
-    $data->{total} = 0;
-    $data->{total} += $data->{$_} foreach keys %$data;
+    my $data = $_[0]->{data};
+    # don't double-calculate the total
+    return $data if $data->{total};
+
+    my $total = 0;
+    $total += $data->{$_} foreach keys %$data;
+    $data->{total} = $total;
     return $data;
 }
 
--------------------------------------------------------------------------------