data: flatten only returns historical data

This commit is contained in:
Paul Beckingham 2016-05-28 13:25:01 -04:00
parent 06123411d7
commit 2e314b5809

View file

@ -29,6 +29,7 @@
#include <Datetime.h>
#include <Duration.h>
#include <timew.h>
#include <iostream>
////////////////////////////////////////////////////////////////////////////////
// A filter is just another interval, containing start, end and tags.
@ -385,12 +386,23 @@ std::vector <Interval> flatten (
if (interval.range.encloses (e))
enclosed.push_back (e);
Datetime now;
for (auto& result : subtractRanges ({interval.range}, enclosed))
{
Interval chunk {interval};
chunk.range = result;
// Only historical data is included.
if (chunk.range.start <= now)
{
// A future range.end should be truncated.
if (! chunk.range.is_open () &&
chunk.range.end >= now)
chunk.range.end = now;
all.push_back (chunk);
}
}
/*
std::cout << "# results:\n";