Merge branch 'recurrence' into 2.6.0

This commit is contained in:
Paul Beckingham 2017-01-07 12:29:11 -05:00
commit 4e7576cb79
65 changed files with 652 additions and 484 deletions

View file

@ -38,29 +38,35 @@
extern Context context;
////////////////////////////////////////////////////////////////////////////////
void dependencyGetBlocked (const Task& task, std::vector <Task>& blocked)
std::vector <Task> dependencyGetBlocked (const Task& task)
{
std::string uuid = task.get ("uuid");
auto all = context.tdb2.pending.get_tasks ();
for (auto& it : all)
std::vector <Task> blocked;
for (auto& it : context.tdb2.pending.get_tasks ())
if (it.getStatus () != Task::completed &&
it.getStatus () != Task::deleted &&
it.has ("depends") &&
it.get ("depends").find (uuid) != std::string::npos)
blocked.push_back (it);
return blocked;
}
////////////////////////////////////////////////////////////////////////////////
void dependencyGetBlocking (const Task& task, std::vector <Task>& blocking)
std::vector <Task> dependencyGetBlocking (const Task& task)
{
std::string depends = task.get ("depends");
std::vector <Task> blocking;
if (depends != "")
for (auto& it : context.tdb2.pending.get_tasks ())
if (it.getStatus () != Task::completed &&
it.getStatus () != Task::deleted &&
depends.find (it.get ("uuid")) != std::string::npos)
blocking.push_back (it);
return blocking;
}
////////////////////////////////////////////////////////////////////////////////
@ -82,8 +88,7 @@ bool dependencyIsCircular (const Task& task)
while (! s.empty ())
{
Task& current = s.top ();
std::vector <std::string> deps_current;
current.getDependencies (deps_current);
auto deps_current = current.getDependencyUUIDs ();
// This is a basic depth first search that always terminates given the
// fact that we do not visit any task twice
@ -146,14 +151,12 @@ bool dependencyIsCircular (const Task& task)
//
void dependencyChainOnComplete (Task& task)
{
std::vector <Task> blocking;
dependencyGetBlocking (task, blocking);
auto blocking = dependencyGetBlocking (task);
// If the task is anything but the tail end of a dependency chain.
if (blocking.size ())
{
std::vector <Task> blocked;
dependencyGetBlocked (task, blocked);
auto blocked = dependencyGetBlocked (task);
// Nag about broken chain.
if (context.config.getBoolean ("dependency.reminder"))
@ -206,8 +209,7 @@ void dependencyChainOnStart (Task& task)
{
if (context.config.getBoolean ("dependency.reminder"))
{
std::vector <Task> blocking;
dependencyGetBlocking (task, blocking);
auto blocking = dependencyGetBlocking (task);
// If the task is anything but the tail end of a dependency chain, nag about
// broken chain.