Skip to content

Commit

Permalink
Fixed sibling pipeline aggs
Browse files Browse the repository at this point in the history
  • Loading branch information
VladLasitsa committed Oct 13, 2022
1 parent ad24cfd commit e659105
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/plugins/vis_types/xy/public/convert_to_lens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { METRIC_TYPES } from '@kbn/data-plugin/public';
import { Column, ColumnWithMeta } from '@kbn/visualizations-plugin/common';
import {
convertToLensModule,
Expand All @@ -27,6 +28,13 @@ export interface Layer {
collapseFn?: string;
}

const SIBBLING_PIPELINE_AGGS: string[] = [
METRIC_TYPES.AVG_BUCKET,
METRIC_TYPES.SUM_BUCKET,
METRIC_TYPES.MAX_BUCKET,
METRIC_TYPES.MIN_BUCKET,
];

export const isColumnWithMeta = (column: Column): column is ColumnWithMeta => {
if ((column as ColumnWithMeta).meta) {
return true;
Expand Down Expand Up @@ -98,7 +106,14 @@ export const convertToLens: ConvertXYToLensVisualization = async (vis, timefilte
visibleSeries
.reduce<Array<{ metrics: string[]; type: string; mode: string }>>((acc, s) => {
const series = acc.find(({ type, mode }) => type === s.type && mode === s.mode);
if (series) {
// sibling pipeline agg always generate new layer because of custom bucket
if (
series &&
visSchemas.metric.some(
(m) =>
m.aggId?.split('.')[0] === s.data.id && !SIBBLING_PIPELINE_AGGS.includes(m.aggType)
)
) {
series.metrics.push(s.data.id);
} else {
acc.push({ metrics: [s.data.id], type: s.type, mode: s.mode });
Expand Down

0 comments on commit e659105

Please sign in to comment.