mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
- Added averages to the "task history" report.
This commit is contained in:
parent
f61c849816
commit
cc9235033f
4 changed files with 26 additions and 8 deletions
|
@ -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 -----------------------------------
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
<ul>
|
||||
<li>Added "task undelete" feature to restore a (very) recently deleted
|
||||
task
|
||||
<li>Added averages to the "task history" report
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -313,7 +313,7 @@ std::string Date::monthName (int month)
|
|||
|
||||
assert (month > 0);
|
||||
assert (month <= 12);
|
||||
return months[month -1];
|
||||
return months[month - 1];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
30
src/task.cpp
30
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 ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue