diff --git a/src/data.cpp b/src/data.cpp index ce8d078f..68f2ebbb 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -574,11 +574,12 @@ Interval clip (const Interval& interval, const Range& range) } //////////////////////////////////////////////////////////////////////////////// -std::vector getTrackedIntervals ( +std::vector getTracked ( Database& database, const Rules& rules, Interval& filter) { +// std::cout << "# getTracked\n"; auto inclusions = getAllInclusions (database); // Exclusions are only usable within a range, so if no filter range exists, @@ -595,30 +596,21 @@ std::vector getTrackedIntervals ( } // Get the set of expanded exclusions that overlap the range defined by the - // timeline. If no range is defined, derive it from the set of all data. + // timeline. auto exclusions = getAllExclusions (rules, filter.range); - Datetime now; + if (! exclusions.size ()) + return inclusions; std::vector intervals; - for (auto& inclusion : subset (filter, inclusions)) - for (auto& e : exclusions) - if (e.start < now) - { - if (inclusion.range.encloses (e)) - { - // Subtract any enclosed exclusion. - for (auto& result : subtractRanges (filter.range, {inclusion.range}, {e})) - { - Interval chunk {inclusion}; - chunk.range = result; - intervals.push_back (chunk); - } - } - else - { - intervals.push_back (inclusion); - } - } + for (auto& inclusion : inclusions) + { + for (auto& piece : subtractRanges (filter.range, {inclusion.range}, exclusions)) + { + Interval chunk {inclusion}; + chunk.range = piece; + intervals.push_back (chunk); + } + } return intervals; } diff --git a/src/timew.h b/src/timew.h index 01541e96..866f2feb 100644 --- a/src/timew.h +++ b/src/timew.h @@ -50,7 +50,7 @@ std::vector subtractRanges (const Range&, const std::vector &); bool matchesFilter (const Interval&, const Interval&); Interval clip (const Interval&, const Range&); -std::vector getTrackedIntervals (Database&, const Rules&, Interval&); +std::vector getTracked (Database&, const Rules&, Interval&); std::vector getUntrackedRanges (Database&, const Rules&, Interval&); Interval getLatestInterval (Database&); Range getFullDay (const Datetime&);