[hamster-applet] rounding error in the grand total. fixes bug 622027



commit 4c0778b52aaf83b13f0ffd371ac18f2f14eafff0
Author: Toms Bauģis <toms baugis gmail com>
Date:   Sun Jun 20 23:28:23 2010 +0100

    rounding error in the grand total. fixes bug 622027

 src/hamster/overview_totals.py |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/hamster/overview_totals.py b/src/hamster/overview_totals.py
index a5794ec..766a3b2 100644
--- a/src/hamster/overview_totals.py
+++ b/src/hamster/overview_totals.py
@@ -141,18 +141,17 @@ class TotalsBox(gtk.VBox):
     def calculate_totals(self):
         if not self.facts:
             return
+        facts = self.facts
 
-        import copy
-        facts = copy.deepcopy(self.facts)
+        total_hours = dt.timedelta()
 
-        total_hours = sum([stuff.duration_minutes(fact["delta"]) for fact in facts])
-        total_label = _("%s hours tracked total") % locale.format("%.1f", total_hours / 60.0)
-        self.get_widget("total_hours").set_text(total_label)
 
 
         category_sums, activity_sums, tag_sums = defaultdict(dt.timedelta), defaultdict(dt.timedelta), defaultdict(dt.timedelta),
 
         for fact in facts:
+            total_hours += fact["delta"]
+
             if self.selected_categories and fact["category"] not in self.selected_categories:
                 continue
             if self.selected_activities and fact["name"] not in self.selected_activities:
@@ -165,6 +164,9 @@ class TotalsBox(gtk.VBox):
             for tag in fact["tags"]:
                 tag_sums[tag] += fact["delta"]
 
+        total_label = _("%s hours tracked total") % locale.format("%.1f", stuff.duration_minutes(total_hours) / 60.0)
+        self.get_widget("total_hours").set_text(total_label)
+
 
         for key in category_sums:
             category_sums[key] = stuff.duration_minutes(category_sums[key]) / 60.0



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]