TW-1572: Implement better urgency inheritance
- Implement recursive urgency inheritance. If this is to be made a default setting, some thought will have to be put into making it more efficient.
This commit is contained in:
@@ -154,8 +154,8 @@ std::string Config::_defaults =
|
||||
"urgency.tags.coefficient=1.0 # Urgency coefficient for tags\n"
|
||||
"urgency.project.coefficient=1.0 # Urgency coefficient for projects\n"
|
||||
"urgency.blocked.coefficient=-5.0 # Urgency coefficient for blocked tasks\n"
|
||||
"urgency.inherit.coefficient=0.0 # Urgency coefficient for blocked tasks inheriting from blocking tasks\n"
|
||||
"urgency.waiting.coefficient=-3.0 # Urgency coefficient for waiting status\n"
|
||||
"urgency.inherit=off # Recursively inherit highest urgency value from blocked tasks\n"
|
||||
"urgency.age.max=365 # Maximum age in days\n"
|
||||
"\n"
|
||||
"#urgency.user.project.foo.coefficient=5.0 # Urgency coefficients for 'foo' project\n"
|
||||
|
||||
@@ -643,7 +643,6 @@ void Context::staticInitialization ()
|
||||
Task::urgencyScheduledCoefficient = config.getReal ("urgency.scheduled.coefficient");
|
||||
Task::urgencyWaitingCoefficient = config.getReal ("urgency.waiting.coefficient");
|
||||
Task::urgencyBlockedCoefficient = config.getReal ("urgency.blocked.coefficient");
|
||||
Task::urgencyInheritCoefficient = config.getReal ("urgency.inherit.coefficient");
|
||||
Task::urgencyAnnotationsCoefficient = config.getReal ("urgency.annotations.coefficient");
|
||||
Task::urgencyTagsCoefficient = config.getReal ("urgency.tags.coefficient");
|
||||
Task::urgencyNextCoefficient = config.getReal ("urgency.next.coefficient");
|
||||
|
||||
32
src/Task.cpp
32
src/Task.cpp
@@ -30,6 +30,7 @@
|
||||
#include <assert.h>
|
||||
#ifdef PRODUCT_TASKWARRIOR
|
||||
#include <math.h>
|
||||
#include <cfloat>
|
||||
#endif
|
||||
#include <algorithm>
|
||||
#ifdef PRODUCT_TASKWARRIOR
|
||||
@@ -76,7 +77,6 @@ float Task::urgencyActiveCoefficient = 0.0;
|
||||
float Task::urgencyScheduledCoefficient = 0.0;
|
||||
float Task::urgencyWaitingCoefficient = 0.0;
|
||||
float Task::urgencyBlockedCoefficient = 0.0;
|
||||
float Task::urgencyInheritCoefficient = 0.0;
|
||||
float Task::urgencyAnnotationsCoefficient = 0.0;
|
||||
float Task::urgencyTagsCoefficient = 0.0;
|
||||
float Task::urgencyNextCoefficient = 0.0;
|
||||
@@ -1621,7 +1621,6 @@ float Task::urgency_c () const
|
||||
value += fabsf (Task::urgencyDueCoefficient) > epsilon ? (urgency_due () * Task::urgencyDueCoefficient) : 0.0;
|
||||
value += fabsf (Task::urgencyBlockingCoefficient) > epsilon ? (urgency_blocking () * Task::urgencyBlockingCoefficient) : 0.0;
|
||||
value += fabsf (Task::urgencyAgeCoefficient) > epsilon ? (urgency_age () * Task::urgencyAgeCoefficient) : 0.0;
|
||||
value += fabsf (Task::urgencyInheritCoefficient) > epsilon ? (urgency_inherit () * Task::urgencyInheritCoefficient) : 0.0;
|
||||
|
||||
// Tag- and project-specific coefficients.
|
||||
for (auto& var : Task::coefficients)
|
||||
@@ -1686,6 +1685,17 @@ float Task::urgency_c () const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_blocking && context.config.getBoolean ("urgency.inherit"))
|
||||
{
|
||||
float prev = value;
|
||||
value = std::max (value, urgency_inherit ());
|
||||
|
||||
// This is a hackish way of making sure parent tasks are sorted above
|
||||
// child tasks. For reports that hide blocked tasks, this is not needed.
|
||||
if (prev < value)
|
||||
value += 0.01;
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
@@ -1708,28 +1718,16 @@ float Task::urgency ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
float Task::urgency_inherit () const
|
||||
{
|
||||
if (!is_blocking)
|
||||
return 0.0;
|
||||
|
||||
// Calling dependencyGetBlocked is rather expensive.
|
||||
// It is called recursively for each dependency in the chain here.
|
||||
std::vector <Task> blocked;
|
||||
dependencyGetBlocked (*this, blocked);
|
||||
|
||||
float v = 0.0;
|
||||
float v = FLT_MIN;
|
||||
for (auto& task : blocked)
|
||||
{
|
||||
// urgency_blocked, _blocking, _project and _tags left out.
|
||||
v += task.urgency_active ();
|
||||
v += task.urgency_age ();
|
||||
v += task.urgency_annotations ();
|
||||
v += task.urgency_due ();
|
||||
v += task.urgency_next ();
|
||||
v += task.urgency_scheduled ();
|
||||
v += task.urgency_waiting ();
|
||||
|
||||
// Inherit from all parent tasks in the dependency chain recursively.
|
||||
v += task.urgency_inherit ();
|
||||
// Find highest urgency in all blocked tasks.
|
||||
v = std::max (v, task.urgency ());
|
||||
}
|
||||
|
||||
return v;
|
||||
|
||||
@@ -48,7 +48,6 @@ public:
|
||||
static float urgencyScheduledCoefficient;
|
||||
static float urgencyWaitingCoefficient;
|
||||
static float urgencyBlockedCoefficient;
|
||||
static float urgencyInheritCoefficient;
|
||||
static float urgencyAnnotationsCoefficient;
|
||||
static float urgencyTagsCoefficient;
|
||||
static float urgencyNextCoefficient;
|
||||
|
||||
@@ -194,7 +194,6 @@ int CmdShow::execute (std::string& output)
|
||||
" urgency.annotations.coefficient"
|
||||
" urgency.blocked.coefficient"
|
||||
" urgency.blocking.coefficient"
|
||||
" urgency.inherit.coefficient"
|
||||
" urgency.due.coefficient"
|
||||
" urgency.next.coefficient"
|
||||
" urgency.project.coefficient"
|
||||
@@ -202,6 +201,7 @@ int CmdShow::execute (std::string& output)
|
||||
" urgency.waiting.coefficient"
|
||||
" urgency.age.coefficient"
|
||||
" urgency.age.max"
|
||||
" urgency.inherit"
|
||||
" verbose"
|
||||
" weekstart"
|
||||
" xterm.title"
|
||||
|
||||
@@ -133,6 +133,10 @@ std::string legacyCheckForDeprecatedVariables ()
|
||||
// Deprecated іn 2.4.0.
|
||||
if (it.first == "alias._query")
|
||||
deprecated.push_back (it.first);
|
||||
|
||||
// Deprecated in 2.4.5.
|
||||
if (it.first == "urgency.inherit.coefficient")
|
||||
deprecated.push_back (it.first);
|
||||
}
|
||||
|
||||
std::stringstream out;
|
||||
|
||||
Reference in New Issue
Block a user