mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
TI-58: Fix bug 'Delete command is not always deleting'
- Update database before deleting sythetic intervals - Make Exclusion::ranges work with open interval
This commit is contained in:
parent
98218c4b75
commit
ad67539f94
4 changed files with 35 additions and 3 deletions
2
AUTHORS
2
AUTHORS
|
@ -23,6 +23,7 @@ The following submitted code, packages or analysis, and deserve special thanks:
|
||||||
Richard Brown
|
Richard Brown
|
||||||
Armado Martinez
|
Armado Martinez
|
||||||
A M
|
A M
|
||||||
|
asmyers
|
||||||
|
|
||||||
Thanks to the following, who submitted detailed bug reports and excellent
|
Thanks to the following, who submitted detailed bug reports and excellent
|
||||||
suggestions:
|
suggestions:
|
||||||
|
@ -51,3 +52,4 @@ suggestions:
|
||||||
Jan Stolarek
|
Jan Stolarek
|
||||||
Yury Videneev
|
Yury Videneev
|
||||||
Bodo Graumann
|
Bodo Graumann
|
||||||
|
Lynoure
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
(thanks to Mattia Rizzolo).
|
(thanks to Mattia Rizzolo).
|
||||||
- TI-52 The 'refresh' scripts overwrites previous years data
|
- TI-52 The 'refresh' scripts overwrites previous years data
|
||||||
(thanks to m8r).
|
(thanks to m8r).
|
||||||
|
- TI-58 Delete command is not always deleting
|
||||||
|
(thanks to Lynoure, asmyers).
|
||||||
- TI-61 Typo in exclusion.t.cpp
|
- TI-61 Typo in exclusion.t.cpp
|
||||||
(thanks to Thomas Lauf).
|
(thanks to Thomas Lauf).
|
||||||
- TI-64 Command 'stop' with date before current interval's start date causes segfault
|
- TI-64 Command 'stop' with date before current interval's start date causes segfault
|
||||||
|
|
|
@ -120,7 +120,15 @@ std::vector <Range> Exclusion::ranges (const Range& range) const
|
||||||
else if ((dayOfWeek = Datetime::dayOfWeek (_tokens[1])) != -1)
|
else if ((dayOfWeek = Datetime::dayOfWeek (_tokens[1])) != -1)
|
||||||
{
|
{
|
||||||
Datetime start (range.start.year (), range.start.month (), range.start.day (), 0, 0, 0);
|
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)
|
if (start.dayOfWeek () == dayOfWeek)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +140,7 @@ std::vector <Range> Exclusion::ranges (const Range& range) const
|
||||||
for (unsigned int block = 2; block < _tokens.size (); ++block)
|
for (unsigned int block = 2; block < _tokens.size (); ++block)
|
||||||
{
|
{
|
||||||
auto r = rangeFromTimeBlock (_tokens[block], start, end);
|
auto r = rangeFromTimeBlock (_tokens[block], start, end);
|
||||||
if (range.overlap (r))
|
if (myRange.overlap (r))
|
||||||
results.push_back (r);
|
results.push_back (r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,12 +50,32 @@ int CmdDelete (
|
||||||
Interval filter;
|
Interval filter;
|
||||||
auto tracked = getTracked (database, rules, filter);
|
auto tracked = getTracked (database, rules, filter);
|
||||||
|
|
||||||
// Apply tags to ids.
|
bool dirty = true;
|
||||||
|
|
||||||
for (auto& id : ids)
|
for (auto& id : ids)
|
||||||
{
|
{
|
||||||
if (id > static_cast <int> (tracked.size ()))
|
if (id > static_cast <int> (tracked.size ()))
|
||||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
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]);
|
database.deleteInterval (tracked[tracked.size () - id]);
|
||||||
|
|
||||||
if (rules.getBoolean ("verbose"))
|
if (rules.getBoolean ("verbose"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue