- Added averages to the "task history" report.

This commit is contained in:
Paul Beckingham
2008-06-22 01:04:33 -04:00
parent f61c849816
commit cc9235033f
4 changed files with 26 additions and 8 deletions

View File

@@ -14,6 +14,7 @@ represents a feature release, and the Z represents a patch.
1.4.0 () 1.4.0 ()
+ "task undelete" can now undelete erroneously deleted tasks, provided no + "task undelete" can now undelete erroneously deleted tasks, provided no
reports have been run (and therefore TDB::gc run) reports have been run (and therefore TDB::gc run)
+ Added averages to the "task history" report
------ reality ----------------------------------- ------ reality -----------------------------------

View File

@@ -50,6 +50,7 @@
<ul> <ul>
<li>Added "task undelete" feature to restore a (very) recently deleted <li>Added "task undelete" feature to restore a (very) recently deleted
task task
<li>Added averages to the "task history" report
</ul> </ul>
<p> <p>

View File

@@ -313,7 +313,7 @@ std::string Date::monthName (int month)
assert (month > 0); assert (month > 0);
assert (month <= 12); assert (month <= 12);
return months[month -1]; return months[month - 1];
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@@ -1600,16 +1600,19 @@ void handleReportHistory (const TDB& tdb, T& task, Config& conf)
table.setColumnJustification (4, Table::right); table.setColumnJustification (4, Table::right);
table.setColumnJustification (5, Table::right); table.setColumnJustification (5, Table::right);
const char *months[] = int totalAdded = 0;
{ int totalCompleted = 0;
"January", "February", "March", "April", "May", "June", int totalDeleted = 0;
"July", "August", "September", "October", "November", "December",
};
int priorYear = 0; int priorYear = 0;
int row = 0;
foreach (i, groups) 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); Date dt (i->first);
int m, d, y; int m, d, y;
@@ -1620,7 +1623,7 @@ void handleReportHistory (const TDB& tdb, T& task, Config& conf)
table.addCell (row, 0, y); table.addCell (row, 0, y);
priorYear = y; priorYear = y;
} }
table.addCell (row, 1, months[m - 1]); table.addCell (row, 1, Date::monthName(m));
int net = 0; 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); 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 ()) if (table.rowCount ())
std::cout << optionalBlankLine (conf) std::cout << optionalBlankLine (conf)
<< table.render () << table.render ()