mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 00:57:19 +02:00
Enhancement - ghistory report
- Implemented the ghistory report.
This commit is contained in:
parent
9f6b112003
commit
a09246fd71
2 changed files with 40 additions and 81 deletions
|
@ -174,8 +174,8 @@ std::string Context::dispatch ()
|
||||||
else if (cmd.command == "stats") { out = handleReportStats (); }
|
else if (cmd.command == "stats") { out = handleReportStats (); }
|
||||||
else if (cmd.command == "info") { out = handleInfo (); }
|
else if (cmd.command == "info") { out = handleInfo (); }
|
||||||
else if (cmd.command == "history") { out = handleReportHistory (); }
|
else if (cmd.command == "history") { out = handleReportHistory (); }
|
||||||
/*
|
|
||||||
else if (cmd.command == "ghistory") { out = handleReportGHistory (); }
|
else if (cmd.command == "ghistory") { out = handleReportGHistory (); }
|
||||||
|
/*
|
||||||
else if (cmd.command == "calendar") { out = handleReportCalendar (); }
|
else if (cmd.command == "calendar") { out = handleReportCalendar (); }
|
||||||
else if (cmd.command == "summary") { out = handleReportSummary (); }
|
else if (cmd.command == "summary") { out = handleReportSummary (); }
|
||||||
else if (cmd.command == "timesheet") { out = handleReportTimesheet (); }
|
else if (cmd.command == "timesheet") { out = handleReportTimesheet (); }
|
||||||
|
|
|
@ -993,37 +993,33 @@ std::string handleReportHistory ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string handleReportGHistory ()
|
std::string handleReportGHistory ()
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
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
|
||||||
int widthOfBar = width - 15; // 15 == strlen ("2008 September ")
|
std::map <time_t, int> deletedGroup; // Deletions by month
|
||||||
|
|
||||||
std::map <time_t, int> groups;
|
|
||||||
std::map <time_t, int> addedGroup;
|
|
||||||
std::map <time_t, int> completedGroup;
|
|
||||||
std::map <time_t, int> deletedGroup;
|
|
||||||
|
|
||||||
// Scan the pending tasks.
|
// Scan the pending tasks.
|
||||||
std::vector <T> pending;
|
std::vector <Task> tasks;
|
||||||
tdb.allPendingT (pending);
|
context.tdb.lock (context.config.get ("locking", true));
|
||||||
handleRecurrence (tdb, pending);
|
context.tdb.load (tasks, context.filter);
|
||||||
filter (pending, task);
|
context.tdb.unlock ();
|
||||||
for (unsigned int i = 0; i < pending.size (); ++i)
|
// TODO handleRecurrence (tdb, tasks);
|
||||||
{
|
|
||||||
T task (pending[i]);
|
foreach (task, tasks)
|
||||||
time_t epoch = monthlyEpoch (task.getAttribute ("entry"));
|
|
||||||
if (epoch)
|
|
||||||
{
|
{
|
||||||
|
time_t epoch = monthlyEpoch (task->get ("entry"));
|
||||||
groups[epoch] = 0;
|
groups[epoch] = 0;
|
||||||
|
|
||||||
|
// Every task has an entry date.
|
||||||
if (addedGroup.find (epoch) != addedGroup.end ())
|
if (addedGroup.find (epoch) != addedGroup.end ())
|
||||||
addedGroup[epoch] = addedGroup[epoch] + 1;
|
addedGroup[epoch] = addedGroup[epoch] + 1;
|
||||||
else
|
else
|
||||||
addedGroup[epoch] = 1;
|
addedGroup[epoch] = 1;
|
||||||
|
|
||||||
if (task.getStatus () == T::deleted)
|
// All deleted tasks have an end date.
|
||||||
|
if (task->getStatus () == Task::deleted)
|
||||||
{
|
{
|
||||||
epoch = monthlyEpoch (task.getAttribute ("end"));
|
epoch = monthlyEpoch (task->get ("end"));
|
||||||
groups[epoch] = 0;
|
groups[epoch] = 0;
|
||||||
|
|
||||||
if (deletedGroup.find (epoch) != deletedGroup.end ())
|
if (deletedGroup.find (epoch) != deletedGroup.end ())
|
||||||
|
@ -1031,9 +1027,11 @@ std::string handleReportGHistory ()
|
||||||
else
|
else
|
||||||
deletedGroup[epoch] = 1;
|
deletedGroup[epoch] = 1;
|
||||||
}
|
}
|
||||||
else if (task.getStatus () == T::completed)
|
|
||||||
|
// All completed tasks have an end date.
|
||||||
|
else if (task->getStatus () == Task::completed)
|
||||||
{
|
{
|
||||||
epoch = monthlyEpoch (task.getAttribute ("end"));
|
epoch = monthlyEpoch (task->get ("end"));
|
||||||
groups[epoch] = 0;
|
groups[epoch] = 0;
|
||||||
|
|
||||||
if (completedGroup.find (epoch) != completedGroup.end ())
|
if (completedGroup.find (epoch) != completedGroup.end ())
|
||||||
|
@ -1042,48 +1040,8 @@ std::string handleReportGHistory ()
|
||||||
completedGroup[epoch] = 1;
|
completedGroup[epoch] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Scan the completed tasks.
|
int widthOfBar = context.getWidth () - 15; // 15 == strlen ("2008 September ")
|
||||||
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)
|
|
||||||
{
|
|
||||||
groups[epoch] = 0;
|
|
||||||
|
|
||||||
if (addedGroup.find (epoch) != addedGroup.end ())
|
|
||||||
addedGroup[epoch] = addedGroup[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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now build the table.
|
// Now build the table.
|
||||||
Table table;
|
Table table;
|
||||||
|
@ -1202,6 +1160,7 @@ std::string handleReportGHistory ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::stringstream out;
|
||||||
if (table.rowCount ())
|
if (table.rowCount ())
|
||||||
{
|
{
|
||||||
out << optionalBlankLine ()
|
out << optionalBlankLine ()
|
||||||
|
@ -1222,7 +1181,7 @@ std::string handleReportGHistory ()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
out << "No tasks." << std::endl;
|
out << "No tasks." << std::endl;
|
||||||
*/
|
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue