mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Dependencies
- Added dependencyGetBlocking and dependencyGetBlocked API calls, in the ongoing effort to find a workable API for dependencies. The goal is to make the calling code as small as possible when dealing with dependencies. - Corrected the algorithm for determining whether a task is blocked or blocking to also check that the other task is pending or waiting. For example: task add one task add two depends:1 task do 1 As the first task is completed, task 2 still depends on 1, but is no longer blocked due to the completed status. - Modified the "info" report to use the modified API.
This commit is contained in:
parent
8904daf9e5
commit
975c2bbcb9
3 changed files with 66 additions and 24 deletions
|
@ -440,37 +440,33 @@ int handleInfo (std::string &outs)
|
|||
// dependencies: blocked
|
||||
if (task->has ("depends"))
|
||||
{
|
||||
std::vector <Task> blocked;
|
||||
dependencyGetBlocked (*task, blocked);
|
||||
|
||||
std::stringstream message;
|
||||
std::vector <Task>::const_iterator it;
|
||||
for (it = blocked.begin (); it != blocked.end (); ++it)
|
||||
message << it->id << " " << it->get ("description") << "\n";
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "This task blocked by");
|
||||
|
||||
std::string depends = task->get ("depends");
|
||||
const std::vector <Task>& rpending = context.tdb.getAllPending ();
|
||||
|
||||
std::stringstream blocked;
|
||||
std::vector <Task>::const_iterator it;
|
||||
for (it = rpending.begin (); it != rpending.end (); ++it)
|
||||
if (depends.find (it->get ("uuid")) != std::string::npos)
|
||||
blocked << it->id << " " << it->get ("description") << "\n";
|
||||
|
||||
table.addCell (row, 1, blocked.str ());
|
||||
table.addCell (row, 1, message.str ());
|
||||
}
|
||||
|
||||
// dependencies: blocking
|
||||
{
|
||||
std::string uuid = task->get ("uuid");
|
||||
const std::vector <Task>& rpending = context.tdb.getAllPending ();
|
||||
|
||||
std::stringstream blocked;
|
||||
std::vector <Task>::const_iterator it;
|
||||
for (it = rpending.begin (); it != rpending.end (); ++it)
|
||||
if (it->get ("depends").find (uuid) != std::string::npos)
|
||||
blocked << it->id << " " << it->get ("description") << "\n";
|
||||
|
||||
if (blocked.str().length ())
|
||||
std::vector <Task> blocking;
|
||||
dependencyGetBlocking (*task, blocking);
|
||||
if (blocking.size ())
|
||||
{
|
||||
std::stringstream message;
|
||||
std::vector <Task>::const_iterator it;
|
||||
for (it = blocking.begin (); it != blocking.end (); ++it)
|
||||
message << it->id << " " << it->get ("description") << "\n";
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 0, "This task is blocking");
|
||||
table.addCell (row, 1, blocked.str ());
|
||||
table.addCell (row, 1, message.str ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue