From cc9235033fef6ce9e8c077651208046e386ab1fa Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 22 Jun 2008 01:04:33 -0400 Subject: [PATCH] - Added averages to the "task history" report. --- ChangeLog | 1 + html/task.html | 1 + src/Date.cpp | 2 +- src/task.cpp | 30 +++++++++++++++++++++++------- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 91999bc7a..3cd5e66b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ represents a feature release, and the Z represents a patch. 1.4.0 () + "task undelete" can now undelete erroneously deleted tasks, provided no reports have been run (and therefore TDB::gc run) + + Added averages to the "task history" report ------ reality ----------------------------------- diff --git a/html/task.html b/html/task.html index 6273c3df4..cca2f99ff 100644 --- a/html/task.html +++ b/html/task.html @@ -50,6 +50,7 @@

diff --git a/src/Date.cpp b/src/Date.cpp index 45172fb29..cd535e231 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -313,7 +313,7 @@ std::string Date::monthName (int month) assert (month > 0); assert (month <= 12); - return months[month -1]; + return months[month - 1]; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/task.cpp b/src/task.cpp index cfbad7379..c86149bb9 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -1600,16 +1600,19 @@ void handleReportHistory (const TDB& tdb, T& task, Config& conf) table.setColumnJustification (4, Table::right); table.setColumnJustification (5, Table::right); - const char *months[] = - { - "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December", - }; + int totalAdded = 0; + int totalCompleted = 0; + int totalDeleted = 0; int priorYear = 0; + int row = 0; foreach (i, groups) { - int row = table.addRow (); + row = table.addRow (); + + totalAdded += addedGroup[i->first]; + totalCompleted += completedGroup[i->first]; + totalDeleted += deletedGroup[i->first]; Date dt (i->first); int m, d, y; @@ -1620,7 +1623,7 @@ void handleReportHistory (const TDB& tdb, T& task, Config& conf) table.addCell (row, 0, y); priorYear = y; } - table.addCell (row, 1, months[m - 1]); + table.addCell (row, 1, Date::monthName(m)); int net = 0; @@ -1647,6 +1650,19 @@ void handleReportHistory (const TDB& tdb, T& task, Config& conf) table.setCellFg (row, 5, net > 0 ? Text::red: Text::green); } + if (table.rowCount ()) + { + table.addRow (); + row = table.addRow (); + + table.addCell (row, 1, "Average"); + if (conf.get ("color", true)) table.setRowFg (row, Text::bold); + table.addCell (row, 2, totalAdded / (table.rowCount () - 2)); + table.addCell (row, 3, totalCompleted / (table.rowCount () - 2)); + table.addCell (row, 4, totalDeleted / (table.rowCount () - 2)); + table.addCell (row, 5, (totalAdded - totalCompleted - totalDeleted) / (table.rowCount () - 2)); + } + if (table.rowCount ()) std::cout << optionalBlankLine (conf) << table.render ()