Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Median aggregation labels now show "Median" instead of "50th percentile of" in Visualize #58521

Merged
merged 3 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ describe('AggTypeMetricMedianProvider class', () => {
schema: 'metric',
params: {
field: 'bytes',
percents: [70],
},
},
],
Expand All @@ -58,12 +57,21 @@ describe('AggTypeMetricMedianProvider class', () => {
it('requests the percentiles aggregation in the Elasticsearch query DSL', () => {
const dsl: Record<string, any> = aggConfigs.toDsl();

expect(dsl.median.percentiles.percents).toEqual([70]);
expect(dsl.median.percentiles.field).toEqual('bytes');
expect(dsl.median.percentiles.percents).toEqual([50]);
});

it('asks Elasticsearch for array-based values in the aggregation response', () => {
const dsl: Record<string, any> = aggConfigs.toDsl();
it('converts the response', () => {
const agg = aggConfigs.getResponseAggs()[0];

expect(dsl.median.percentiles.keyed).toBeFalsy();
expect(
agg.getValue({
[agg.id]: {
values: {
'50.0': 10,
},
},
})
).toEqual(10);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,13 @@ export const medianMetricAgg = new MetricAggType({
name: 'field',
type: 'field',
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.DATE],
},
{
name: 'percents',
default: [50],
},
{
write(agg, output) {
output.params.keyed = false;
output.params.field = agg.getParam('field').name;
output.params.percents = [50];
},
},
],
getResponseAggs: percentilesMetricAgg.getResponseAggs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only needed for multi-value aggs. Replaced by getValue.

getValue: percentilesMetricAgg.getValue,
getValue(agg, bucket) {
return bucket[agg.id].values['50.0'];
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const getPercentileValue = <TAggConfig extends IResponseAggConfig>(
agg: TAggConfig,
bucket: any
) => {
const { values } = bucket[agg.parentId] && bucket[agg.parentId];
const { values } = bucket[agg.parentId];

const percentile: any = find(values, ({ key }) => key === agg.key);

Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_metric_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function({ getService, getPageObjects }) {
});

it('should show Median', async function() {
const medianBytes = ['5,565.263', '50th percentile of bytes'];
const medianBytes = ['5,565.263', 'Median bytes'];
// For now, only comparing the text label part of the metric
log.debug('Aggregation = Median');
await PageObjects.visEditor.selectAggregation('Median', 'metrics');
Expand Down