Integration - "tags" report

- The "tags" report is now working under 1.8.0.
This commit is contained in:
Paul Beckingham 2009-06-08 01:24:33 -04:00
parent fb5fe5f5b4
commit aff828c51b
4 changed files with 15 additions and 14 deletions

View file

@ -163,8 +163,8 @@ void Context::dispatch ()
if (command == "export") { out = handleExport (tdb, task); } if (command == "export") { out = handleExport (tdb, task); }
*/ */
if (cmd.command == "projects") { out = handleProjects (); } if (cmd.command == "projects") { out = handleProjects (); }
else if (cmd.command == "tags") { out = handleTags (); }
/* /*
else if (command == "tags") { out = handleTags (tdb, task); }
else if (command == "info") { out = handleInfo (tdb, task); } else if (command == "info") { out = handleInfo (tdb, task); }
else if (command == "stats") { out = handleReportStats (tdb, task); } else if (command == "stats") { out = handleReportStats (tdb, task); }
else if (command == "history") { out = handleReportHistory (tdb, task); } else if (command == "history") { out = handleReportHistory (tdb, task); }

View file

@ -101,6 +101,7 @@ std::string handleProjects ()
std::vector <T2> tasks; std::vector <T2> tasks;
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
int quantity = context.tdb.load (tasks, context.filter); int quantity = context.tdb.load (tasks, context.filter);
context.tdb.unlock ();
// Scan all the tasks for their project name, building a map using project // Scan all the tasks for their project name, building a map using project
// names as keys. // names as keys.
@ -144,31 +145,31 @@ std::string handleProjects ()
out << "No projects." out << "No projects."
<< std::endl; << std::endl;
context.tdb.unlock ();
return out.str (); return out.str ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleTags (TDB& tdb, T& task) std::string handleTags ()
{ {
std::stringstream out; std::stringstream out;
// Get all the tasks. context.filter.push_back (Att ("status", "pending"));
std::vector <T> tasks;
tdb.pendingT (tasks); std::vector <T2> tasks;
context.tdb.lock (context.config.get ("locking", true));
int quantity = context.tdb.load (tasks, context.filter);
context.tdb.unlock ();
// Scan all the tasks for their project name, building a map using project // Scan all the tasks for their project name, building a map using project
// names as keys. // names as keys.
std::map <std::string, std::string> unique; std::map <std::string, std::string> unique;
for (unsigned int i = 0; i < tasks.size (); ++i) foreach (t, tasks)
{ {
T task (tasks[i]);
std::vector <std::string> tags; std::vector <std::string> tags;
task.getTags (tags); t->getTags (tags);
for (unsigned int t = 0; t < tags.size (); ++t) foreach (tag, tags)
unique[tags[t]] = ""; unique[*tag] = "";
} }
// Render a list of tag names from the map. // Render a list of tag names from the map.
@ -180,6 +181,7 @@ std::string handleTags (TDB& tdb, T& task)
out << optionalBlankLine () out << optionalBlankLine ()
<< unique.size () << unique.size ()
<< (unique.size () == 1 ? " tag" : " tags") << (unique.size () == 1 ? " tag" : " tags")
<< " (" << quantity << (quantity == 1 ? " task" : " tasks") << ")"
<< std::endl; << std::endl;
else else
out << "No tags." out << "No tags."

View file

@ -453,7 +453,6 @@ std::string runTaskCommand (
// Read-only commands with no side effects. // Read-only commands with no side effects.
if (command == "export") { out = handleExport (tdb, task); } if (command == "export") { out = handleExport (tdb, task); }
else if (command == "tags") { out = handleTags (tdb, task); }
else if (command == "info") { out = handleInfo (tdb, task); } else if (command == "info") { out = handleInfo (tdb, task); }
else if (command == "stats") { out = handleReportStats (tdb, task); } else if (command == "stats") { out = handleReportStats (tdb, task); }
else if (command == "history") { out = handleReportHistory (tdb, task); } else if (command == "history") { out = handleReportHistory (tdb, task); }

View file

@ -69,7 +69,7 @@ std::string handleExport (TDB&, T&);
std::string handleDone (TDB&, T&); std::string handleDone (TDB&, T&);
std::string handleModify (TDB&, T&); std::string handleModify (TDB&, T&);
std::string handleProjects (); std::string handleProjects ();
std::string handleTags (TDB&, T&); std::string handleTags ();
std::string handleUndelete (TDB&, T&); std::string handleUndelete (TDB&, T&);
std::string handleVersion (); std::string handleVersion ();
std::string handleDelete (TDB&, T&); std::string handleDelete (TDB&, T&);