- Added a coefficient for ageing which is the increase (or decrease)
   of urgency per day. The calculated urgency offset due to ageing
   can be limited by setting urgency.age.max.
This commit is contained in:
Johannes Schlatow 2011-12-15 10:10:17 +01:00
parent 52f70f6901
commit 3d33d90d57
5 changed files with 40 additions and 0 deletions

View file

@ -1231,6 +1231,8 @@ float Task::urgency_c () const
value += urgency_next () * context.config.getReal ("urgency.next.coefficient");
value += urgency_due () * context.config.getReal ("urgency.due.coefficient");
value += urgency_blocking () * context.config.getReal ("urgency.blocking.coefficient");
value += urgency_age (context.config.getReal ("urgency.age.coefficient"),
context.config.getReal ("urgency.age.max"));
// Tag- and project-specific coefficients.
std::vector <std::string> all;
@ -1399,6 +1401,30 @@ float Task::urgency_due () const
return 0.0;
}
////////////////////////////////////////////////////////////////////////////////
float Task::urgency_age (float coefficient, float max) const
{
if (coefficient == 0) {
return 0.0;
}
else if (has ("entry"))
{
Date now;
Date entry (get_date ("entry"));
int age = (now - entry) / 86400;
float result = age * coefficient;
if (max == 0) // unlimited
return result;
else if (max > 0)
return (result > max) ? max : result;
else
return (result < max) ? max : result;
}
return 0.0;
}
////////////////////////////////////////////////////////////////////////////////
float Task::urgency_blocking () const
{