diff --git a/AUTHORS b/AUTHORS index 0d5a7599..817aa348 100644 --- a/AUTHORS +++ b/AUTHORS @@ -23,6 +23,7 @@ The following submitted code, packages or analysis, and deserve special thanks: Richard Brown Armado Martinez A M + asmyers Thanks to the following, who submitted detailed bug reports and excellent suggestions: @@ -51,3 +52,4 @@ suggestions: Jan Stolarek Yury Videneev Bodo Graumann + Lynoure diff --git a/ChangeLog b/ChangeLog index 2ea202e5..3ac55515 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,8 @@ (thanks to Mattia Rizzolo). - TI-52 The 'refresh' scripts overwrites previous years data (thanks to m8r). +- TI-58 Delete command is not always deleting + (thanks to Lynoure, asmyers). - TI-61 Typo in exclusion.t.cpp (thanks to Thomas Lauf). - TI-64 Command 'stop' with date before current interval's start date causes segfault diff --git a/src/Exclusion.cpp b/src/Exclusion.cpp index fbe1d1c6..2ee02be9 100644 --- a/src/Exclusion.cpp +++ b/src/Exclusion.cpp @@ -120,7 +120,15 @@ std::vector Exclusion::ranges (const Range& range) const else if ((dayOfWeek = Datetime::dayOfWeek (_tokens[1])) != -1) { Datetime start (range.start.year (), range.start.month (), range.start.day (), 0, 0, 0); - while (start <= range.end) + + Range myRange = {range}; + + if (myRange.is_open()) + { + myRange.end = Datetime("tomorrow"); + } + + while (start <= myRange.end) { if (start.dayOfWeek () == dayOfWeek) { @@ -132,7 +140,7 @@ std::vector Exclusion::ranges (const Range& range) const for (unsigned int block = 2; block < _tokens.size (); ++block) { auto r = rangeFromTimeBlock (_tokens[block], start, end); - if (range.overlap (r)) + if (myRange.overlap (r)) results.push_back (r); } } diff --git a/src/commands/CmdDelete.cpp b/src/commands/CmdDelete.cpp index ebc0cdce..65916c38 100644 --- a/src/commands/CmdDelete.cpp +++ b/src/commands/CmdDelete.cpp @@ -50,12 +50,32 @@ int CmdDelete ( Interval filter; auto tracked = getTracked (database, rules, filter); - // Apply tags to ids. + bool dirty = true; + for (auto& id : ids) { if (id > static_cast (tracked.size ())) throw format ("ID '@{1}' does not correspond to any tracking.", id); + if (tracked[tracked.size() - id].synthetic && dirty) + { + auto latest = getLatestInterval(database); + auto exclusions = getAllExclusions (rules, filter.range); + + Interval modified {latest}; + + // Update database. + database.deleteInterval (latest); + for (auto& interval : flatten (modified, exclusions)) + database.addInterval (interval); + + dirty = false; + } + } + + // Delete intervals by id + for (auto& id : ids) + { database.deleteInterval (tracked[tracked.size () - id]); if (rules.getBoolean ("verbose"))