use of org.graylog.plugins.views.search.searchtypes.pivot.buckets.DateRange in project graylog2-server by Graylog2.
the class PivotAggregationSearch method buildDateRangeBuckets.
@VisibleForTesting
static DateRangeBucket buildDateRangeBuckets(TimeRange timeRange, long searchWithinMs, long executeEveryMs) {
final ImmutableList.Builder<DateRange> ranges = ImmutableList.builder();
DateTime from = timeRange.getFrom();
DateTime to;
do {
// The smallest configurable unit is 1 sec.
// By dividing it before casting we avoid a potential int overflow
to = from.plusSeconds((int) (searchWithinMs / 1000));
ranges.add(DateRange.builder().from(from).to(to).build());
from = from.plusSeconds((int) executeEveryMs / 1000);
} while (to.isBefore(timeRange.getTo()));
return DateRangeBucket.builder().field("timestamp").ranges(ranges.build()).build();
}
Aggregations