mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
validate: Uses helper function to find overlaps
This commit is contained in:
parent
7c8c1df46f
commit
c1dd9df929
1 changed files with 7 additions and 17 deletions
|
@ -97,29 +97,19 @@ static void autoAdjust (
|
||||||
Database& database,
|
Database& database,
|
||||||
Interval& interval)
|
Interval& interval)
|
||||||
{
|
{
|
||||||
// Without (adjust == true), overlapping intervals are an error condition.
|
auto overlaps = getOverlaps (database, rules, interval);
|
||||||
|
|
||||||
// An empty filter allows scanning beyond interval.range.
|
|
||||||
Interval range_filter;
|
|
||||||
auto tracked = getTracked (database, rules, range_filter);
|
|
||||||
|
|
||||||
// Find all overlapping intervals.
|
|
||||||
std::vector <Interval> overlapping;
|
|
||||||
for (auto& track : tracked)
|
|
||||||
if (interval.range.overlap (track.range))
|
|
||||||
overlapping.push_back (track);
|
|
||||||
|
|
||||||
// Diagnostics.
|
|
||||||
debug ("Input " + interval.dump ());
|
debug ("Input " + interval.dump ());
|
||||||
debug ("Overlaps with");
|
debug ("Overlaps with");
|
||||||
for (auto& overlap : overlapping)
|
for (auto& overlap : overlaps)
|
||||||
debug (" " + overlap.dump ());
|
debug (" " + overlap.dump ());
|
||||||
|
|
||||||
// Overlaps are forbidden.
|
// Without (adjust == true), overlapping intervals are an error condition.
|
||||||
if (! adjust && overlapping.size ())
|
if (! adjust && overlaps.size ())
|
||||||
throw std::string ("You cannot overlap intervals. Correct the start/end "
|
throw std::string ("You cannot overlap intervals. Correct the start/end "
|
||||||
"time, or specify the :adjust hint.");
|
"time, or specify the :adjust hint.");
|
||||||
|
|
||||||
|
// TODO If there is overlap, and the tags are the same, merge.
|
||||||
|
|
||||||
// TODO Accumulate identifiable and correctable cases here.
|
// TODO Accumulate identifiable and correctable cases here.
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue