diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 769c3be67..44469db7a 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -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 diff --git a/src/Config.cpp b/src/Config.cpp index bf0c23ae9..53a02fad1 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -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" diff --git a/src/Task.cpp b/src/Task.cpp index 123b94597..dc36db880 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -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 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 { diff --git a/src/Task.h b/src/Task.h index 6032c19da..08f0760e9 100644 --- a/src/Task.h +++ b/src/Task.h @@ -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 diff --git a/src/commands/CmdShow.cpp b/src/commands/CmdShow.cpp index 27cc2ebad..552186cd6 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -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"