mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Do not delete and then re-add the latest interval when flattening Database
Eliminates extra noise in the debug output. I.e. from #422 the original report contained: >> 2021-05.data: Deleted inc 20210511T161243Z # "TRACKER-6145" >> 2021-05.data: Added inc 20210511T161243Z # "TRACKER-6145" Which isn't doing anything. Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
This commit is contained in:
parent
bba56cc633
commit
73970b3755
1 changed files with 16 additions and 5 deletions
21
src/data.cpp
21
src/data.cpp
|
@ -127,6 +127,7 @@ std::vector <Range> getAllExclusions (
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Convert what would be synthetic intervals into real intervals in the database
|
||||
void flattenDatabase (Database& database, const Rules& rules)
|
||||
{
|
||||
auto latest = getLatestInterval (database);
|
||||
|
@ -135,13 +136,23 @@ void flattenDatabase (Database& database, const Rules& rules)
|
|||
auto exclusions = getAllExclusions (rules, {latest.start, Datetime ()});
|
||||
if (! exclusions.empty ())
|
||||
{
|
||||
Interval modified {latest};
|
||||
std::vector <Interval> flattened = flatten (latest, exclusions);
|
||||
|
||||
// Update database.
|
||||
database.deleteInterval (latest);
|
||||
for (auto& interval : flatten (modified, exclusions))
|
||||
// If flattened returns only the latest then there are not any synthetic
|
||||
// intervals to convert.
|
||||
if (flattened.size () > 1)
|
||||
{
|
||||
database.addInterval (interval, rules.getBoolean ("verbose"));
|
||||
// Update database.
|
||||
bool verbose = rules.getBoolean ("verbose");
|
||||
database.deleteInterval (latest);
|
||||
for (auto& interval : flattened)
|
||||
{
|
||||
database.addInterval (interval, verbose);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert (latest == flattened[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue