From af6f2b55ec47bc1660dd143e78999ada7694adc8 Mon Sep 17 00:00:00 2001 From: Vladyslav Tronko Date: Wed, 7 Jul 2021 21:05:30 +0300 Subject: [PATCH] Fix matching project name during urgency calculation --- src/Task.cpp | 6 +++++- src/commands/CmdInfo.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Task.cpp b/src/Task.cpp index 8748c1d50..8b7b740f7 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1841,6 +1841,7 @@ float Task::urgency_c () const value += fabsf (Task::urgencyBlockingCoefficient) > epsilon ? (urgency_blocking () * Task::urgencyBlockingCoefficient) : 0.0; value += fabsf (Task::urgencyAgeCoefficient) > epsilon ? (urgency_age () * Task::urgencyAgeCoefficient) : 0.0; + const std::string taskProjectName = get("project"); // Tag- and project-specific coefficients. for (auto& var : Task::coefficients) { @@ -1855,8 +1856,11 @@ float Task::urgency_c () const { std::string project = var.first.substr (21, end - 21); - if (get ("project").find (project) == 0) + if (taskProjectName == project || + taskProjectName.find(project + '.') == 0) + { value += var.second; + } } // urgency.user.tag..coefficient diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index c40d287f0..c398d94b7 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -468,8 +468,12 @@ int CmdInfo::execute (std::string& output) (end = var.first.find (".coefficient")) != std::string::npos) { auto project = var.first.substr (21, end - 21); - if (task.get ("project").find (project) == 0) + const std::string taskProjectName = task.get("project"); + if (taskProjectName == project || + taskProjectName.find(project + '.') == 0) + { urgencyTerm (urgencyDetails, "PROJECT " + project, 1.0, var.second); + } } // urgency.user.tag..coefficient