Add support for task expiration (#3546)

This commit is contained in:
Dustin J. Mitchell 2024-07-09 16:39:39 -04:00 committed by GitHub
parent 2bd609afe3
commit 213b9d3aee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 180 additions and 7 deletions

View file

@ -172,6 +172,7 @@ std::vector<NewsItem> NewsItem::all () {
std::vector<NewsItem> items;
version2_6_0(items);
version3_0_0(items);
version3_1_0(items);
return items;
}
@ -537,6 +538,27 @@ void NewsItem::version3_0_0 (std::vector<NewsItem>& items) {
items.push_back(sync);
}
void NewsItem::version3_1_0 (std::vector<NewsItem>& items) {
Version version("3.1.0");
NewsItem sync {
version,
/*title=*/"Purging and Expiring Tasks",
/*bg_title=*/"",
/*background=*/"",
/*punchline=*/
"Support for `task purge` has been restored, and new support added for automatically expiring\n"
"old tasks.\n\n"
/*update=*/
"The `task purge` command removes tasks entirely, in contrast to `task delete` which merely sets\n"
"the task status to 'Deleted'. This functionality existed in versions 2.x but was temporarily\n"
"removed in 3.0.\n\n"
"The new `expiration.on-sync` configuration parameter controls automatic expiration of old tasks.\n"
"An old task is one with status 'Deleted' that has not been modified in 180 days. This\n"
"functionality is optional and not enabled by default."
};
items.push_back(sync);
}
////////////////////////////////////////////////////////////////////////////////
int CmdNews::execute (std::string& output)
{

View file

@ -49,6 +49,7 @@ public:
static std::vector<NewsItem> all();
static void version2_6_0 (std::vector<NewsItem>&);
static void version3_0_0 (std::vector<NewsItem>&);
static void version3_1_0 (std::vector<NewsItem>&);
private:
NewsItem (

View file

@ -160,6 +160,7 @@ int CmdShow::execute (std::string& output)
" due"
" editor"
" exit.on.missing.db"
" expiration.on-sync"
" expressions"
" fontunderline"
" gc"

View file

@ -106,7 +106,12 @@ int CmdSync::execute (std::string& output)
<< '\n';
}
Context::getContext ().tdb2.sync(std::move(server), false);
Context &context = Context::getContext ();
context.tdb2.sync(std::move(server), false);
if (context.config.getBoolean ("expiration.on-sync")) {
context.tdb2.expire_tasks ();
}
output = out.str ();
return status;