Skip to content

Commit

Permalink
Revert "[Lens] dont use legacy metric in the suggestions (#197101)"
Browse files Browse the repository at this point in the history
This reverts commit 6f44bf5.
  • Loading branch information
mbondyra authored Oct 22, 2024
1 parent 6f44bf5 commit b19ba37
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('metric_suggestions', () => {
expect(rest).toHaveLength(0);
expect(suggestion).toMatchInlineSnapshot(`
Object {
"hide": true,
"hide": false,
"previewIcon": [Function],
"score": 0.1,
"state": Object {
Expand Down Expand Up @@ -207,7 +207,7 @@ describe('metric_suggestions', () => {
expect(rest).toHaveLength(0);
expect(suggestion).toMatchInlineSnapshot(`
Object {
"hide": true,
"hide": false,
"previewIcon": [Function],
"score": 0.1,
"state": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function getSuggestion(

return {
title,
hide: true,
hide: datasourceId === 'textBased',
score: 0.1,
previewIcon: IconChartMetric,
state: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('metric suggestions', () => {
// should ignore bucketed column for initial drag
},
title: 'Metric',
hide: false,
hide: true,
previewIcon: IconChartMetric,
score: 0.51,
},
Expand Down Expand Up @@ -189,7 +189,7 @@ describe('metric suggestions', () => {
breakdownByAccessor: bucketColumn.columnId,
},
title: 'Metric',
hide: false,
hide: true,
previewIcon: IconChartMetric,
score: 0.51,
},
Expand Down Expand Up @@ -221,7 +221,7 @@ describe('metric suggestions', () => {
breakdownByAccessor: bucketColumn.columnId,
},
title: 'Metric',
hide: false,
hide: true,
previewIcon: IconChartMetric,
score: 0.51,
},
Expand Down Expand Up @@ -294,7 +294,7 @@ describe('metric suggestions', () => {
breakdownByAccessor: bucketColumn.columnId,
},
title: 'Metric',
hide: false,
hide: true,
previewIcon: IconChartMetric,
score: 0.52,
},
Expand Down Expand Up @@ -326,7 +326,7 @@ describe('metric suggestions', () => {
breakdownByAccessor: bucketColumn.columnId,
},
title: 'Metric',
hide: false,
hide: true,
previewIcon: IconChartMetric,
score: 0.52,
},
Expand Down Expand Up @@ -357,7 +357,7 @@ describe('metric suggestions', () => {
breakdownByAccessor: bucketColumn.columnId,
},
title: 'Metric',
hide: false,
hide: true,
previewIcon: IconChartMetric,
score: 0.52,
},
Expand Down
13 changes: 4 additions & 9 deletions x-pack/plugins/lens/public/visualizations/metric/suggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export const getSuggestions: Visualization<MetricVisualizationState>['getSuggest

const bucketedColumns = table.columns.filter(({ operation }) => operation.isBucketed);

const hasInterval = bucketedColumns.some(({ operation }) => operation.scale === 'interval');

const unsupportedColumns = table.columns.filter(
({ operation }) => !supportedDataTypes.has(operation.dataType) && !operation.isBucketed
);
Expand Down Expand Up @@ -61,10 +59,11 @@ export const getSuggestions: Visualization<MetricVisualizationState>['getSuggest
layerId: table.layerId,
layerType: LayerTypes.DATA,
},
title: metricColumns[0]?.operation.label || metricLabel,
title: metricLabel,
previewIcon: IconChartMetric,
score: 0.5,
hide: hasInterval,
// don't show suggestions since we're in tech preview
hide: true,
};

const accessorMappings: Pick<MetricVisualizationState, 'metricAccessor' | 'breakdownByAccessor'> =
Expand All @@ -73,11 +72,7 @@ export const getSuggestions: Visualization<MetricVisualizationState>['getSuggest
breakdownByAccessor: bucketedColumns[0]?.columnId,
};

baseSuggestion.score = Number(
(baseSuggestion.score + 0.01 * Object.values(accessorMappings).filter(Boolean).length).toFixed(
2
)
);
baseSuggestion.score += 0.01 * Object.values(accessorMappings).filter(Boolean).length;

const suggestion = {
...baseSuggestion,
Expand Down

0 comments on commit b19ba37

Please sign in to comment.