- 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

@ -957,6 +957,15 @@ Urgency coefficients for tags
.RS
Urgency coefficients for annotations
.RE
.B urgency.age.coefficient=0.0
.RS
Urgency coefficients for the age of tasks
.RE
.B urgency.age.max=0.0
.RS
Maximum (or minimum if negative) urgency a task can reach due to aging. If
this is set to zero, the term will be unlimited.
.RE
The coefficients reflect the relative importance of the various terms in the
urgency calculation. These are default values, and may be modified to suit your

View file

@ -147,6 +147,8 @@ std::string Config::_defaults =
"urgency.project.coefficient=3.0 # Urgency coefficients for projects\n"
"urgency.tags.coefficient=2.0 # Urgency coefficients for tags\n"
"urgency.annotations.coefficient=1.0 # Urgency coefficients for annotations\n"
"urgency.age.coefficient=0 # Urgency coefficients for age\n"
"urgency.age.max=0 # Maximum urgency offset for age\n"
"\n"
"#urgency.user.project.foo.coefficient=5.0 # Urgency coefficients for 'foo' project\n"
"#urgency.user.tag.foo.coefficient=5.0 # Urgency coefficients for 'foo' tag\n"

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
{

View file

@ -117,6 +117,7 @@ private:
inline float urgency_next () const;
inline float urgency_due () const;
inline float urgency_blocking () const;
inline float urgency_age (float, float) const;
};
#endif

View file

@ -196,6 +196,8 @@ int CmdShow::execute (std::string& output)
" urgency.project.coefficient"
" urgency.tags.coefficient"
" urgency.waiting.coefficient"
" urgency.age.coefficient"
" urgency.age.max"
" verbose"
" weekstart"
" xterm.title"