Recurrence: Broke out handleUntil as a separate function

- This means until porocesing is no longer controlled by rc.recurrence, which
  was never intended.
This commit is contained in:
Paul Beckingham 2017-04-06 00:29:20 -04:00
parent e991004c43
commit 97b038ce29
14 changed files with 40 additions and 12 deletions

View file

@ -927,6 +927,7 @@ int CmdBurndownMonthly::execute (std::string& output)
int rc = 0;
// Scan the pending tasks, applying any filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;
@ -962,6 +963,7 @@ int CmdBurndownWeekly::execute (std::string& output)
int rc = 0;
// Scan the pending tasks, applying any filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;
@ -997,6 +999,7 @@ int CmdBurndownDaily::execute (std::string& output)
int rc = 0;
// Scan the pending tasks, applying any filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;

View file

@ -73,6 +73,7 @@ int CmdCalendar::execute (std::string& output)
monthsPerLine = preferredMonthsPerLine;
// Load the pending tasks.
handleUntil ();
handleRecurrence ();
auto tasks = context.tdb2.pending.get_tasks ();

View file

@ -51,6 +51,7 @@ CmdCount::CmdCount ()
int CmdCount::execute (std::string& output)
{
// Apply filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;

View file

@ -91,6 +91,7 @@ int CmdCustom::execute (std::string& output)
context.cli2.addFilter (reportFilter);
// Apply filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;

View file

@ -72,6 +72,7 @@ CmdEdit::CmdEdit ()
int CmdEdit::execute (std::string&)
{
// Filter the tasks.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;

View file

@ -55,6 +55,7 @@ int CmdExport::execute (std::string& output)
int rc = 0;
// Make sure reccurent tasks are generated.
handleUntil ();
handleRecurrence ();
// Apply filter.

View file

@ -335,6 +335,7 @@ int CmdHistoryBase<HistoryStrategy>::execute (std::string& output)
completedGroup.clear ();
// Apply filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;

View file

@ -58,6 +58,7 @@ CmdIDs::CmdIDs ()
int CmdIDs::execute (std::string& output)
{
// Apply filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;
@ -151,6 +152,7 @@ CmdCompletionIds::CmdCompletionIds ()
int CmdCompletionIds::execute (std::string& output)
{
// Apply filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;
@ -189,6 +191,7 @@ CmdZshCompletionIds::CmdZshCompletionIds ()
int CmdZshCompletionIds::execute (std::string& output)
{
// Apply filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;
@ -229,6 +232,7 @@ CmdUUIDs::CmdUUIDs ()
int CmdUUIDs::execute (std::string& output)
{
// Apply filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;
@ -265,6 +269,7 @@ CmdCompletionUuids::CmdCompletionUuids ()
int CmdCompletionUuids::execute (std::string& output)
{
// Apply filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;
@ -301,6 +306,7 @@ CmdZshCompletionUuids::CmdZshCompletionUuids ()
int CmdZshCompletionUuids::execute (std::string& output)
{
// Apply filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;

View file

@ -60,6 +60,7 @@ int CmdProjects::execute (std::string& output)
int rc = 0;
// Get all the tasks.
handleUntil ();
handleRecurrence ();
auto tasks = context.tdb2.pending.get_tasks ();
@ -178,6 +179,7 @@ CmdCompletionProjects::CmdCompletionProjects ()
int CmdCompletionProjects::execute (std::string& output)
{
// Get all the tasks.
handleUntil ();
handleRecurrence ();
auto tasks = context.tdb2.pending.get_tasks ();

View file

@ -66,6 +66,7 @@ int CmdSummary::execute (std::string& output)
bool showAllProjects = context.config.getBoolean ("summary.all.projects");
// Apply filter.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;

View file

@ -81,6 +81,7 @@ int CmdTimesheet::execute (std::string& output)
}
// Apply filter to get a set of tasks.
handleUntil ();
handleRecurrence ();
Filter filter;
std::vector <Task> filtered;

View file

@ -44,6 +44,7 @@ void updateRecurrenceMask (Task&);
// recur2.cpp
void handleRecurrence2 ();
void handleUntil ();
// nag.cpp
bool nag (Task&);

View file

@ -139,18 +139,6 @@ void handleRecurrence ()
context.footnote (format (STRING_RECUR_CREATE, t.get ("description")));
}
}
// Non-recurring tasks expire too.
else
{
if (t.has ("until") &&
Datetime (t.get_date ("until")) < now)
{
t.setStatus (Task::deleted);
context.tdb2.modify(t);
context.footnote (onExpiration (t));
}
}
}
}

View file

@ -27,6 +27,7 @@
#include <cmake.h>
#include <Datetime.h>
#include <Context.h>
#include <main.h>
extern Context context;
@ -82,3 +83,22 @@ void handleRecurrence2 ()
}
////////////////////////////////////////////////////////////////////////////////
// Delete expired tasks.
void handleUntil ()
{
Datetime now;
auto tasks = context.tdb2.pending.get_tasks ();
for (auto& t : tasks)
{
if (t.getStatus () == Task::pending &&
t.has ("until") &&
Datetime (t.get_date ("until")) < now)
{
t.setStatus (Task::deleted);
context.tdb2.modify(t);
context.footnote (onExpiration (t));
}
}
}
////////////////////////////////////////////////////////////////////////////////