From 86ef048cb098a76d6cdcf459501d0a82c1f76f91 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 24 Apr 2011 11:36:43 -0400 Subject: [PATCH] Bug #605 + Fixed bug #605, which gave misleading project completion percentages under certain circumstances (thanks to Steve Rader). --- ChangeLog | 2 ++ src/report.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 31d1e573b..43a247965 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,8 @@ + Added feature #714, including Belarus holidays (thanks to Alexei Romanoff). # Tracked Bugs, sorted by ID. + + Fixed bug #605, which gave misleading project completion percentages under + certain circumstances (thanks to Steve Rader). + Fixed bug #703, where global substitutions didn't make all expected annotation changes. + Fixed bug #707, which had inverted logic with the urgency calculation for diff --git a/src/report.cpp b/src/report.cpp index 7b7b4eb2d..eb4012a3b 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -2194,8 +2194,18 @@ std::string onProjectChange (Task& task, bool scope /* = true */) countTasks (all, project, context.tdb.getAllModified (), count_pending, count_done); countTasks (context.tdb.getAllModified (), project, (std::vector ) NULL, count_pending, count_done); + // count_done count_pending percentage + // ---------- ------------- ---------- + // 0 0 0% + // >0 0 100% + // 0 >0 0% + // >0 >0 calculated int percentage = 0; - if (count_done + count_pending > 0) + if (count_done == 0) + percentage = 0; + else if (count_pending == 0) + percentage = 100; + else percentage = (count_done * 100 / (count_done + count_pending)); msg << "Project '"