mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Urgency
- Age-dependet urgency calculation now normalizes.
This commit is contained in:
parent
3d33d90d57
commit
69fecbb2c0
4 changed files with 15 additions and 19 deletions
|
@ -961,10 +961,9 @@ Urgency coefficients for annotations
|
|||
.RS
|
||||
Urgency coefficients for the age of tasks
|
||||
.RE
|
||||
.B urgency.age.max=0.0
|
||||
.B urgency.age.max=365
|
||||
.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.
|
||||
Maximum age in days. After this number of days has elapsed, the urgency of a task won't increase any more because of aging.
|
||||
.RE
|
||||
|
||||
The coefficients reflect the relative importance of the various terms in the
|
||||
|
|
|
@ -148,7 +148,7 @@ std::string Config::_defaults =
|
|||
"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"
|
||||
"urgency.age.max=365 # Maximum age in days\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"
|
||||
|
|
25
src/Task.cpp
25
src/Task.cpp
|
@ -1231,8 +1231,7 @@ 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"));
|
||||
value += urgency_age () * context.config.getReal ("urgency.age.coefficient");
|
||||
|
||||
// Tag- and project-specific coefficients.
|
||||
std::vector <std::string> all;
|
||||
|
@ -1402,24 +1401,22 @@ float Task::urgency_due () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
float Task::urgency_age (float coefficient, float max) const
|
||||
float Task::urgency_age () const
|
||||
{
|
||||
if (coefficient == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
else if (has ("entry"))
|
||||
if (has ("entry"))
|
||||
{
|
||||
Date now;
|
||||
Date entry (get_date ("entry"));
|
||||
int age = (now - entry) / 86400; // in days
|
||||
float max = context.config.getReal ("urgency.age.max");
|
||||
|
||||
int age = (now - entry) / 86400;
|
||||
float result = age * coefficient;
|
||||
if (max == 0) // unlimited
|
||||
return result;
|
||||
else if (max > 0)
|
||||
return (result > max) ? max : result;
|
||||
if (max == 0)
|
||||
return 1.0;
|
||||
|
||||
if (age > max)
|
||||
return 1.0;
|
||||
else
|
||||
return (result < max) ? max : result;
|
||||
return (1.0 * age/max);
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
|
|
|
@ -117,7 +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;
|
||||
inline float urgency_age () const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue