Skip to content

Commit

Permalink
Fix tsvb filter ration for table (elastic#77272)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
VladLasitsa and elasticmachine committed Sep 15, 2020
1 parent de6ebc3 commit 2f3f497
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,27 @@
*/

const filter = (metric) => metric.type === 'filter_ratio';
import { esQuery } from '../../../../../../data/server';
import { bucketTransform } from '../../helpers/bucket_transform';
import { overwrite } from '../../helpers';
import { calculateAggRoot } from './calculate_agg_root';

export function ratios(req, panel) {
export function ratios(req, panel, esQueryConfig, indexPatternObject) {
return (next) => (doc) => {
panel.series.forEach((column) => {
const aggRoot = calculateAggRoot(doc, column);
if (column.metrics.some(filter)) {
column.metrics.filter(filter).forEach((metric) => {
overwrite(doc, `${aggRoot}.timeseries.aggs.${metric.id}-numerator.filter`, {
query_string: { query: metric.numerator || '*', analyze_wildcard: true },
});
overwrite(doc, `${aggRoot}.timeseries.aggs.${metric.id}-denominator.filter`, {
query_string: { query: metric.denominator || '*', analyze_wildcard: true },
});
overwrite(
doc,
`${aggRoot}.timeseries.aggs.${metric.id}-numerator.filter`,
esQuery.buildEsQuery(indexPatternObject, metric.numerator, [], esQueryConfig)
);
overwrite(
doc,
`${aggRoot}.timeseries.aggs.${metric.id}-denominator.filter`,
esQuery.buildEsQuery(indexPatternObject, metric.denominator, [], esQueryConfig)
);

let numeratorPath = `${metric.id}-numerator>_count`;
let denominatorPath = `${metric.id}-denominator>_count`;
Expand All @@ -46,7 +51,7 @@ export function ratios(req, panel) {
}),
};
overwrite(doc, `${aggRoot}.timeseries.aggs.${metric.id}-numerator.aggs`, aggBody);
overwrite(doc, `${aggBody}.timeseries.aggs.${metric.id}-denominator.aggs`, aggBody);
overwrite(doc, `${aggRoot}.timeseries.aggs.${metric.id}-denominator.aggs`, aggBody);
numeratorPath = `${metric.id}-numerator>metric`;
denominatorPath = `${metric.id}-denominator>metric`;
}
Expand Down

0 comments on commit 2f3f497

Please sign in to comment.