mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
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:
parent
e991004c43
commit
97b038ce29
14 changed files with 40 additions and 12 deletions
|
@ -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;
|
||||
|
|
|
@ -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 ();
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ CmdCount::CmdCount ()
|
|||
int CmdCount::execute (std::string& output)
|
||||
{
|
||||
// Apply filter.
|
||||
handleUntil ();
|
||||
handleRecurrence ();
|
||||
Filter filter;
|
||||
std::vector <Task> filtered;
|
||||
|
|
|
@ -91,6 +91,7 @@ int CmdCustom::execute (std::string& output)
|
|||
context.cli2.addFilter (reportFilter);
|
||||
|
||||
// Apply filter.
|
||||
handleUntil ();
|
||||
handleRecurrence ();
|
||||
Filter filter;
|
||||
std::vector <Task> filtered;
|
||||
|
|
|
@ -72,6 +72,7 @@ CmdEdit::CmdEdit ()
|
|||
int CmdEdit::execute (std::string&)
|
||||
{
|
||||
// Filter the tasks.
|
||||
handleUntil ();
|
||||
handleRecurrence ();
|
||||
Filter filter;
|
||||
std::vector <Task> filtered;
|
||||
|
|
|
@ -55,6 +55,7 @@ int CmdExport::execute (std::string& output)
|
|||
int rc = 0;
|
||||
|
||||
// Make sure reccurent tasks are generated.
|
||||
handleUntil ();
|
||||
handleRecurrence ();
|
||||
|
||||
// Apply filter.
|
||||
|
|
|
@ -335,6 +335,7 @@ int CmdHistoryBase<HistoryStrategy>::execute (std::string& output)
|
|||
completedGroup.clear ();
|
||||
|
||||
// Apply filter.
|
||||
handleUntil ();
|
||||
handleRecurrence ();
|
||||
Filter filter;
|
||||
std::vector <Task> filtered;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -44,6 +44,7 @@ void updateRecurrenceMask (Task&);
|
|||
|
||||
// recur2.cpp
|
||||
void handleRecurrence2 ();
|
||||
void handleUntil ();
|
||||
|
||||
// nag.cpp
|
||||
bool nag (Task&);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue