Skip to content

Commit

Permalink
[TSVB] Add support for Math Aggregation to tables (#14553)
Browse files Browse the repository at this point in the history
* Add support for Math Aggregation to tables

* Removing the range reduction for dropping the last bucket
  • Loading branch information
simianhacker committed Oct 30, 2017
1 parent 79fdf95 commit e765e3b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { calculateAggRoot } from './calculate_agg_root';
export default function dateHistogram(req, panel) {
return next => doc => {
const { timeField, interval } = getIntervalAndTimefield(panel);
const { bucketSize, intervalString } = getBucketSize(req, interval);
const { intervalString } = getBucketSize(req, interval);
const { from, to } = getTimerange(req);
panel.series.forEach(column => {
const aggRoot = calculateAggRoot(doc, column);
Expand All @@ -17,7 +17,7 @@ export default function dateHistogram(req, panel) {
min_doc_count: 0,
extended_bounds: {
min: from.valueOf(),
max: to.valueOf() - (bucketSize * 1000)
max: to.valueOf()
}
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import getBucketSize from '../../helpers/get_bucket_size';
import getTimerange from '../../helpers/get_timerange';
import getIntervalAndTimefield from '../../get_interval_and_timefield';
export default function query(req, panel) {
return next => doc => {
const { timeField, interval } = getIntervalAndTimefield(panel);
const { bucketSize } = getBucketSize(req, interval);
const { timeField } = getIntervalAndTimefield(panel);
const { from, to } = getTimerange(req);

doc.size = 0;
Expand All @@ -18,7 +16,7 @@ export default function query(req, panel) {
range: {
[timeField]: {
gte: from.valueOf(),
lte: to.valueOf() - (bucketSize * 1000),
lte: to.valueOf(),
format: 'epoch_millis',
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { dropLastBucket } from '../series/drop_last_bucket';

export function dropLastBucketFn(bucket, panel, series) {
return next => results => {
const fn = dropLastBucket({ aggregations: bucket }, panel, series);
return fn(next)(results);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
import stdMetric from './std_metric';
import stdSibling from './std_sibling';
import seriesAgg from './series_agg';
import { math } from './math';
import { dropLastBucketFn } from './drop_last_bucket';

export default [
// percentile,
stdMetric,
stdSibling,
seriesAgg
math,
seriesAgg,
dropLastBucketFn
];

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { mathAgg } from '../series/math';

export function math(bucket, panel, series) {
return next => results => {
const mathFn = mathAgg({ aggregations: bucket }, panel, series);
return mathFn(next)(results);
};
}

0 comments on commit e765e3b

Please sign in to comment.