mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-02 14:38:34 +02:00
Bug Fix - nag
- Implemented new nag algorithm, and debugged why it then broke.
This commit is contained in:
parent
8157c729d6
commit
964d04322c
2 changed files with 19 additions and 17 deletions
35
src/task.cpp
35
src/task.cpp
|
@ -334,20 +334,31 @@ void nag (TDB& tdb, T& task, Config& conf)
|
|||
std::string nagMessage = conf.get ("nag", std::string (""));
|
||||
if (nagMessage != "")
|
||||
{
|
||||
// Load all pending.
|
||||
// Load all pending tasks.
|
||||
std::vector <T> pending;
|
||||
tdb.allPendingT (pending);
|
||||
|
||||
// Counters.
|
||||
int overdue = 0;
|
||||
int high = 0;
|
||||
int medium = 0;
|
||||
int low = 0;
|
||||
int overdue = 0;
|
||||
int high = 0;
|
||||
int medium = 0;
|
||||
int low = 0;
|
||||
bool isOverdue = false;
|
||||
char pri = ' ';
|
||||
|
||||
// Scan all pending tasks.
|
||||
foreach (t, pending)
|
||||
{
|
||||
if (t->getId () != task.getId ())
|
||||
if (t->getId () == task.getId ())
|
||||
{
|
||||
if (getDueState (t->getAttribute ("due")) == 2)
|
||||
isOverdue = true;
|
||||
|
||||
std::string priority = t->getAttribute ("priority");
|
||||
if (priority.length ())
|
||||
pri = priority[0];
|
||||
}
|
||||
else if (t->getStatus () == T::pending)
|
||||
{
|
||||
if (getDueState (t->getAttribute ("due")) == 2)
|
||||
overdue++;
|
||||
|
@ -365,21 +376,15 @@ void nag (TDB& tdb, T& task, Config& conf)
|
|||
}
|
||||
}
|
||||
|
||||
// Scan the current task.
|
||||
bool isOverdue = getDueState (task.getAttribute ("due")) == 2 ? true : false;
|
||||
|
||||
char pri = ' ';
|
||||
std::string priority = task.getAttribute ("priority");
|
||||
if (priority.length ())
|
||||
pri = priority[0];
|
||||
|
||||
// General form is "if there are no more deserving tasks", suppress the nag.
|
||||
/*
|
||||
std::cout << "# task.isOverdue = " << (isOverdue ? "true" : "false") << std::endl;
|
||||
std::cout << "# task.pri = " << pri << std::endl;
|
||||
std::cout << "# task.overdue = " << overdue << std::endl;
|
||||
std::cout << "# pending.high = " << high << std::endl;
|
||||
std::cout << "# pending.medium = " << medium << std::endl;
|
||||
std::cout << "# pending.low = " << low << std::endl;
|
||||
*/
|
||||
|
||||
if (isOverdue ) return;
|
||||
if (pri == 'H' && !overdue ) return;
|
||||
|
@ -735,8 +740,6 @@ void updateShadowFile (TDB& tdb, Config& conf)
|
|||
conf.set ("curses", oldCurses);
|
||||
conf.set ("color", oldColor);
|
||||
}
|
||||
else
|
||||
throw std::string ("No specified shadow file '") + shadowFile + "'.";
|
||||
|
||||
// Optionally display a notification that the shadow file was updated.
|
||||
if (conf.get (std::string ("shadow.notify"), false))
|
||||
|
|
|
@ -47,7 +47,6 @@ my $setup = "../task rc:nag.rc add due:yesterday one;"
|
|||
. "../task rc:nag.rc add six;";
|
||||
qx{$setup};
|
||||
|
||||
my $output = qx{../task rc:nag.rc do 6};
|
||||
like (qx{../task rc:nag.rc do 6}, qr/NAG/, 'do pri: -> nag');
|
||||
like (qx{../task rc:nag.rc do 5}, qr/NAG/, 'do pri:L -> nag');
|
||||
like (qx{../task rc:nag.rc do 4}, qr/NAG/, 'do pri:M-> nag');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue