mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-30 02:17:21 +02:00
Enhancement - history report
- Implemented history report. - Improved (not to the point of them working) filters. - Improved automatic filter construction. - Removed obsolete members from Task. - Added tag support to the "add" command.
This commit is contained in:
parent
85e38e67d3
commit
9f6b112003
7 changed files with 89 additions and 111 deletions
115
src/report.cpp
115
src/report.cpp
|
@ -818,7 +818,8 @@ std::string handleReportNext ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Year Month Added Completed Deleted
|
||||
// 2006 November 87 63 14
|
||||
// 2006 December 21 6 1
|
||||
// December 21 6 1
|
||||
// 2007 January 3 12 0
|
||||
time_t monthlyEpoch (const std::string& date)
|
||||
{
|
||||
// Convert any date in epoch form to m/d/y, then convert back
|
||||
|
@ -839,92 +840,51 @@ time_t monthlyEpoch (const std::string& date)
|
|||
|
||||
std::string handleReportHistory ()
|
||||
{
|
||||
std::stringstream out;
|
||||
/*
|
||||
std::map <time_t, int> groups;
|
||||
std::map <time_t, int> addedGroup;
|
||||
std::map <time_t, int> completedGroup;
|
||||
std::map <time_t, int> deletedGroup;
|
||||
std::map <time_t, int> groups; // Represents any month with data
|
||||
std::map <time_t, int> addedGroup; // Additions by month
|
||||
std::map <time_t, int> completedGroup; // Completions by month
|
||||
std::map <time_t, int> deletedGroup; // Deletions by month
|
||||
|
||||
// Scan the pending tasks.
|
||||
std::vector <T> pending;
|
||||
tdb.allPendingT (pending);
|
||||
handleRecurrence (tdb, pending);
|
||||
filter (pending, task);
|
||||
for (unsigned int i = 0; i < pending.size (); ++i)
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.get ("locking", true));
|
||||
context.tdb.load (tasks, context.filter);
|
||||
context.tdb.unlock ();
|
||||
// TODO handleRecurrence (tdb, tasks);
|
||||
|
||||
foreach (task, tasks)
|
||||
{
|
||||
T task (pending[i]);
|
||||
time_t epoch = monthlyEpoch (task.getAttribute ("entry"));
|
||||
if (epoch)
|
||||
time_t epoch = monthlyEpoch (task->get ("entry"));
|
||||
groups[epoch] = 0;
|
||||
|
||||
// Every task has an entry date.
|
||||
if (addedGroup.find (epoch) != addedGroup.end ())
|
||||
addedGroup[epoch] = addedGroup[epoch] + 1;
|
||||
else
|
||||
addedGroup[epoch] = 1;
|
||||
|
||||
// All deleted tasks have an end date.
|
||||
if (task->getStatus () == Task::deleted)
|
||||
{
|
||||
epoch = monthlyEpoch (task->get ("end"));
|
||||
groups[epoch] = 0;
|
||||
|
||||
if (addedGroup.find (epoch) != addedGroup.end ())
|
||||
addedGroup[epoch] = addedGroup[epoch] + 1;
|
||||
if (deletedGroup.find (epoch) != deletedGroup.end ())
|
||||
deletedGroup[epoch] = deletedGroup[epoch] + 1;
|
||||
else
|
||||
addedGroup[epoch] = 1;
|
||||
|
||||
if (task.getStatus () == T::deleted)
|
||||
{
|
||||
epoch = monthlyEpoch (task.getAttribute ("end"));
|
||||
groups[epoch] = 0;
|
||||
|
||||
if (deletedGroup.find (epoch) != deletedGroup.end ())
|
||||
deletedGroup[epoch] = deletedGroup[epoch] + 1;
|
||||
else
|
||||
deletedGroup[epoch] = 1;
|
||||
}
|
||||
else if (task.getStatus () == T::completed)
|
||||
{
|
||||
epoch = monthlyEpoch (task.getAttribute ("end"));
|
||||
groups[epoch] = 0;
|
||||
|
||||
if (completedGroup.find (epoch) != completedGroup.end ())
|
||||
completedGroup[epoch] = completedGroup[epoch] + 1;
|
||||
else
|
||||
completedGroup[epoch] = 1;
|
||||
}
|
||||
deletedGroup[epoch] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Scan the completed tasks.
|
||||
std::vector <T> completed;
|
||||
tdb.allCompletedT (completed);
|
||||
filter (completed, task);
|
||||
for (unsigned int i = 0; i < completed.size (); ++i)
|
||||
{
|
||||
T task (completed[i]);
|
||||
time_t epoch = monthlyEpoch (task.getAttribute ("entry"));
|
||||
if (epoch)
|
||||
// All completed tasks have an end date.
|
||||
else if (task->getStatus () == Task::completed)
|
||||
{
|
||||
epoch = monthlyEpoch (task->get ("end"));
|
||||
groups[epoch] = 0;
|
||||
|
||||
if (addedGroup.find (epoch) != addedGroup.end ())
|
||||
addedGroup[epoch] = addedGroup[epoch] + 1;
|
||||
if (completedGroup.find (epoch) != completedGroup.end ())
|
||||
completedGroup[epoch] = completedGroup[epoch] + 1;
|
||||
else
|
||||
addedGroup[epoch] = 1;
|
||||
|
||||
epoch = monthlyEpoch (task.getAttribute ("end"));
|
||||
if (task.getStatus () == T::deleted)
|
||||
{
|
||||
epoch = monthlyEpoch (task.getAttribute ("end"));
|
||||
groups[epoch] = 0;
|
||||
|
||||
if (deletedGroup.find (epoch) != deletedGroup.end ())
|
||||
deletedGroup[epoch] = deletedGroup[epoch] + 1;
|
||||
else
|
||||
deletedGroup[epoch] = 1;
|
||||
}
|
||||
else if (task.getStatus () == T::completed)
|
||||
{
|
||||
epoch = monthlyEpoch (task.getAttribute ("end"));
|
||||
groups[epoch] = 0;
|
||||
|
||||
if (completedGroup.find (epoch) != completedGroup.end ())
|
||||
completedGroup[epoch] = completedGroup[epoch] + 1;
|
||||
else
|
||||
completedGroup[epoch] = 1;
|
||||
}
|
||||
completedGroup[epoch] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1013,19 +973,20 @@ std::string handleReportHistory ()
|
|||
|
||||
table.addCell (row, 1, "Average");
|
||||
if (context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) table.setRowFg (row, Text::bold);
|
||||
table.addCell (row, 2, totalAdded / (table.rowCount () - 2));
|
||||
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, 4, totalDeleted / (table.rowCount () - 2));
|
||||
table.addCell (row, 5, (totalAdded - totalCompleted - totalDeleted) / (table.rowCount () - 2));
|
||||
}
|
||||
|
||||
std::stringstream out;
|
||||
if (table.rowCount ())
|
||||
out << optionalBlankLine ()
|
||||
<< table.render ()
|
||||
<< std::endl;
|
||||
else
|
||||
out << "No tasks." << std::endl;
|
||||
*/
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue