From 56a897511f5bd6b390f33ee5a7f7c90841fd4db6 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sun, 20 Mar 2016 15:45:15 +0100 Subject: [PATCH] CmdPurge: Simplify implementation --- src/commands/CmdPurge.cpp | 23 ++++++++++++++++------- src/commands/CmdPurge.h | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/commands/CmdPurge.cpp b/src/commands/CmdPurge.cpp index ef9816e3e..040598c19 100644 --- a/src/commands/CmdPurge.cpp +++ b/src/commands/CmdPurge.cpp @@ -51,6 +51,16 @@ CmdPurge::CmdPurge () _category = Command::Category::operation; } +//////////////////////////////////////////////////////////////////////////////// +// Purges the task, while taking care of: +// - dependencies on this task +void CmdPurge::purgeTask (Task& task, int& count) +{ + context.tdb2.purge (task); + handleDeps (task); + count++; +} + //////////////////////////////////////////////////////////////////////////////// // Makes sure that any task having the dependency on the task being purged // has that dependency removed, to preserve referential integrity. @@ -89,8 +99,11 @@ int CmdPurge::execute (std::string&) for (auto& task : filtered) { - std::string uuid = task.get ("uuid"); - + // Allow purging of deleted tasks only. Hence no need to deal with: + // - unblocked tasks notifications (deleted tasks are not blocking) + // - project changes (deleted tasks not included in progress) + // It also has the nice property of being explicit - users need to + // mark tasks as deleted before purging. if (task.getStatus () == Task::deleted) { std::string question; @@ -99,11 +112,7 @@ int CmdPurge::execute (std::string&) task.get ("description")); if (permission (question, filtered.size ())) - { - context.tdb2.purge (task); - handleDeps(task); - count++; - } + purgeTask (task, count); } } diff --git a/src/commands/CmdPurge.h b/src/commands/CmdPurge.h index 76644f3b3..7081e9776 100644 --- a/src/commands/CmdPurge.h +++ b/src/commands/CmdPurge.h @@ -33,6 +33,7 @@ class CmdPurge : public Command { private: + void purgeTask (Task& task, int& count); void handleDeps (Task& task); public: CmdPurge ();