Enhancement

- Re-enabled the onProjectChange function, and upgraded it to TDB2.
  Now it does a lot less, which is another way of saying it is faster.
This commit is contained in:
Paul Beckingham 2011-09-09 00:13:08 -04:00
parent c54bb8a42a
commit d37e46cc48
3 changed files with 15 additions and 38 deletions

View file

@ -60,7 +60,7 @@ int CmdAdd::execute (std::string& output)
if (context.verbose ("new-id")) if (context.verbose ("new-id"))
output = format (STRING_CMD_ADD_FEEDBACK, context.tdb2.next_id ()) + "\n"; output = format (STRING_CMD_ADD_FEEDBACK, context.tdb2.next_id ()) + "\n";
// TODO context.footnote (onProjectChange (task)); context.footnote (onProjectChange (task));
context.tdb2.commit (); context.tdb2.commit ();
return rc; return rc;

View file

@ -66,9 +66,7 @@ int CmdLog::execute (std::string& output)
context.tdb2.add (task); context.tdb2.add (task);
/* context.footnote (onProjectChange (task));
TODO context.footnote (onProjectChange (task));
*/
context.tdb2.commit (); context.tdb2.commit ();
if (context.config.getBoolean ("echo.command")) if (context.config.getBoolean ("echo.command"))

View file

@ -47,7 +47,7 @@
#include <util.h> #include <util.h>
#include <main.h> #include <main.h>
static void countTasks (const std::vector <Task>&, const std::string&, const std::vector <Task>&, int&, int&); static void countTasks (const std::vector <Task>&, const std::string&, int&, int&);
extern Context context; extern Context context;
@ -134,13 +134,8 @@ std::string onProjectChange (Task& task, bool scope /* = true */)
int count_pending = 0; int count_pending = 0;
int count_done = 0; int count_done = 0;
std::vector <Task> all; std::vector <Task> all = context.tdb2.all_tasks ();
std::vector <Task> none; countTasks (all, project, count_pending, count_done);
// TODO Fix.
// context.tdb.load (all);
//
// countTasks (all, project, context.tdb.getAllModified (), count_pending, count_done);
// countTasks (context.tdb.getAllModified (), project, none, count_pending, count_done);
// count_done count_pending percentage // count_done count_pending percentage
// ---------- ------------- ---------- // ---------- ------------- ----------
@ -183,28 +178,13 @@ std::string onProjectChange (Task& task1, Task& task2)
static void countTasks ( static void countTasks (
const std::vector <Task>& all, const std::vector <Task>& all,
const std::string& project, const std::string& project,
const std::vector <Task>& skipTasks,
int& count_pending, int& count_pending,
int& count_done) int& count_done)
{ {
std::vector <Task>::const_iterator it; std::vector <Task>::const_iterator it;
for (it = all.begin (); it != all.end (); ++it) for (it = all.begin (); it != all.end (); ++it)
{ {
bool skip = 0;
if (it->get ("project") == project) if (it->get ("project") == project)
{
std::vector <Task>::const_iterator itSkipTasks;
for (itSkipTasks = skipTasks.begin (); itSkipTasks != skipTasks.end (); ++itSkipTasks)
{
if (it->get("uuid") == itSkipTasks->get("uuid"))
{
skip = 1;
break;
}
}
if (skip == 0)
{ {
switch (it->getStatus ()) switch (it->getStatus ())
{ {
@ -222,7 +202,6 @@ static void countTasks (
} }
} }
} }
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////