Enhancements - summary report

- Implemented summary report.
This commit is contained in:
Paul Beckingham 2009-06-14 12:46:01 -04:00
parent a09246fd71
commit 819c33e491
2 changed files with 26 additions and 25 deletions

View file

@ -175,9 +175,9 @@ std::string Context::dispatch ()
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 == "summary") { out = handleReportSummary (); }
/* /*
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 == "timesheet") { out = handleReportTimesheet (); } else if (cmd.command == "timesheet") { out = handleReportTimesheet (); }
*/ */
else if (cmd.command == "add") { out = handleAdd (); } else if (cmd.command == "add") { out = handleAdd (); }

View file

@ -501,18 +501,18 @@ std::string handleInfo ()
// B 109 3d 12h 10% XXX--------------------- // B 109 3d 12h 10% XXX---------------------
std::string handleReportSummary () std::string handleReportSummary ()
{ {
std::stringstream out; // Scan the pending tasks.
/* std::vector <Task> tasks;
std::vector <T> tasks; context.tdb.lock (context.config.get ("locking", true));
tdb.allT (tasks); context.tdb.load (tasks, context.filter);
handleRecurrence (tdb, tasks); context.tdb.unlock ();
filter (tasks, task); // TODO handleRecurrence (tdb, tasks);
// Generate unique list of project names from all pending tasks. // Generate unique list of project names from all pending tasks.
std::map <std::string, bool> allProjects; std::map <std::string, bool> allProjects;
foreach (t, tasks) foreach (task, tasks)
if (t->getStatus () == T::pending) if (task->getStatus () == Task::pending)
allProjects[t->getAttribute ("project")] = false; allProjects[task->get ("project")] = false;
// Initialize counts, sum. // Initialize counts, sum.
std::map <std::string, int> countPending; std::map <std::string, int> countPending;
@ -522,35 +522,35 @@ std::string handleReportSummary ()
time_t now = time (NULL); time_t now = time (NULL);
// Initialize counters. // Initialize counters.
foreach (i, allProjects) foreach (project, allProjects)
{ {
countPending [i->first] = 0; countPending [project->first] = 0;
countCompleted [i->first] = 0; countCompleted [project->first] = 0;
sumEntry [i->first] = 0.0; sumEntry [project->first] = 0.0;
counter [i->first] = 0; counter [project->first] = 0;
} }
// Count the various tasks. // Count the various tasks.
foreach (t, tasks) foreach (task, tasks)
{ {
std::string project = t->getAttribute ("project"); std::string project = task->get ("project");
++counter[project]; ++counter[project];
if (t->getStatus () == T::pending) if (task->getStatus () == Task::pending)
{ {
++countPending[project]; ++countPending[project];
time_t entry = ::atoi (t->getAttribute ("entry").c_str ()); time_t entry = ::atoi (task->get ("entry").c_str ());
if (entry) if (entry)
sumEntry[project] = sumEntry[project] + (double) (now - entry); sumEntry[project] = sumEntry[project] + (double) (now - entry);
} }
else if (t->getStatus () == T::completed) else if (task->getStatus () == Task::completed)
{ {
++countCompleted[project]; ++countCompleted[project];
time_t entry = ::atoi (t->getAttribute ("entry").c_str ()); time_t entry = ::atoi (task->get ("entry").c_str ());
time_t end = ::atoi (task.getAttribute ("end").c_str ()); time_t end = ::atoi (task->get ("end").c_str ());
if (entry && end) if (entry && end)
sumEntry[project] = sumEntry[project] + (double) (end - entry); sumEntry[project] = sumEntry[project] + (double) (end - entry);
} }
@ -630,6 +630,7 @@ std::string handleReportSummary ()
} }
} }
std::stringstream out;
if (table.rowCount ()) if (table.rowCount ())
out << optionalBlankLine () out << optionalBlankLine ()
<< table.render () << table.render ()
@ -639,7 +640,7 @@ std::string handleReportSummary ()
<< std::endl; << std::endl;
else else
out << "No projects." << std::endl; out << "No projects." << std::endl;
*/
return out.str (); return out.str ();
} }
@ -1252,7 +1253,7 @@ std::string handleReportTimesheet ()
foreach (t, tasks) foreach (t, tasks)
{ {
// If task completed within range. // If task completed within range.
if (t->getStatus () == T::completed) if (t->getStatus () == Task::completed)
{ {
Date compDate (::atoi (t->getAttribute ("end").c_str ())); Date compDate (::atoi (t->getAttribute ("end").c_str ()));
if (compDate >= start && compDate < end) if (compDate >= start && compDate < end)
@ -1322,7 +1323,7 @@ std::string handleReportTimesheet ()
foreach (t, tasks) foreach (t, tasks)
{ {
// If task started within range, but not completed withing range. // If task started within range, but not completed withing range.
if (t->getStatus () == T::pending && if (t->getStatus () == Task::pending &&
t->has ("start")) t->has ("start"))
{ {
Date startDate (::atoi (t->getAttribute ("start").c_str ())); Date startDate (::atoi (t->getAttribute ("start").c_str ()));