Integration - "projects" report

- "projects" report converted to 1.8.0.
- Relocated code from task.cpp to recur.cpp to allow unit tests to link
  without includign task.cpp and therefore main.
- Removed obsolete sandbox directory.
- Fixed bug where Config::load deleted the pre-loaded custom reports.
- Fixed bug where Cmd::valid failed to include custom reports properly.
This commit is contained in:
Paul Beckingham 2009-06-08 00:54:49 -04:00
parent cf67e0142c
commit fb5fe5f5b4
12 changed files with 494 additions and 516 deletions

View file

@ -92,22 +92,21 @@ std::string handleAdd (TDB& tdb, T& task)
}
////////////////////////////////////////////////////////////////////////////////
std::string handleProjects (TDB& tdb, T& task)
std::string handleProjects ()
{
std::stringstream out;
// Get all the tasks, including deleted ones.
std::vector <T> tasks;
tdb.pendingT (tasks);
context.filter.push_back (Att ("status", "pending"));
std::vector <T2> tasks;
context.tdb.lock (context.config.get ("locking", true));
int quantity = context.tdb.load (tasks, context.filter);
// Scan all the tasks for their project name, building a map using project
// names as keys.
std::map <std::string, int> unique;
for (unsigned int i = 0; i < tasks.size (); ++i)
{
T task (tasks[i]);
unique[task.getAttribute ("project")] += 1;
}
foreach (t, tasks)
unique[t->get ("project")] += 1;
if (unique.size ())
{
@ -138,12 +137,14 @@ std::string handleProjects (TDB& tdb, T& task)
<< optionalBlankLine ()
<< unique.size ()
<< (unique.size () == 1 ? " project" : " projects")
<< " (" << quantity << (quantity == 1 ? " task" : " tasks") << ")"
<< std::endl;
}
else
out << "No projects."
<< std::endl;
context.tdb.unlock ();
return out.str ();
}