mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
data: Fixed bug in flatten which yielded multiple intervals
This commit is contained in:
parent
0d0bb19b35
commit
5952652e67
1 changed files with 11 additions and 28 deletions
39
src/data.cpp
39
src/data.cpp
|
@ -410,36 +410,19 @@ std::vector <Interval> flatten (
|
||||||
{
|
{
|
||||||
std::vector <Interval> all;
|
std::vector <Interval> all;
|
||||||
|
|
||||||
// Start with a single range from the interval, from which to subtract.
|
if (! interval.range.ended ())
|
||||||
std::vector <Range> pieces {interval.range};
|
|
||||||
for (auto& exclusion : exclusions)
|
|
||||||
{
|
{
|
||||||
std::vector <Range> split_pieces;
|
all.push_back (interval);
|
||||||
for (auto& piece : pieces)
|
}
|
||||||
{
|
else
|
||||||
// If the exclusion is entirely within the piece, then collapse.
|
{
|
||||||
if (exclusion.start > piece.start &&
|
for (auto& result : subtractRanges (interval.range, {interval.range}, exclusions))
|
||||||
(exclusion.end < piece.end ||
|
{
|
||||||
piece.end.toEpoch () == 0))
|
Interval chunk {interval};
|
||||||
{
|
chunk.range = result;
|
||||||
for (auto& smaller_piece : piece.subtract (exclusion))
|
all.push_back (chunk);
|
||||||
split_pieces.push_back (smaller_piece);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If the exclusion merely overlap the piece, do nothing. This is because
|
|
||||||
// tracked time start and end is not clipped, but recorded faithfully.
|
|
||||||
else
|
|
||||||
{
|
|
||||||
split_pieces.push_back (piece);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pieces = split_pieces;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return all the fragments as clipped intervals.
|
|
||||||
for (auto& piece : pieces)
|
|
||||||
all.push_back (clip (interval, piece));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
std::cout << "# results:\n";
|
std::cout << "# results:\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue