mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
remove tabify performance issue (#124931)
This commit is contained in:
parent
0a8dde3d43
commit
ecff412e22
2 changed files with 41 additions and 3 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { tabifyAggResponse } from './tabify';
|
||||
import { IndexPattern } from '../..';
|
||||
import { AggConfigs, IAggConfig, IAggConfigs } from '../aggs';
|
||||
import { AggConfigs, BucketAggParam, IAggConfig, IAggConfigs } from '../aggs';
|
||||
import { mockAggTypesRegistry } from '../aggs/test_helpers';
|
||||
import { metricOnly, threeTermBuckets } from './fixtures/fake_hierarchical_data';
|
||||
|
||||
|
@ -54,6 +54,42 @@ describe('tabifyAggResponse Integration', () => {
|
|||
expect(resp.columns[0]).toHaveProperty('name', aggConfigs.aggs[0].makeLabel());
|
||||
});
|
||||
|
||||
describe('scaleMetricValues performance check', () => {
|
||||
beforeAll(() => {
|
||||
typesRegistry.get('count').params.push({
|
||||
name: 'scaleMetricValues',
|
||||
default: false,
|
||||
write: () => {},
|
||||
advanced: true,
|
||||
} as any as BucketAggParam<any>);
|
||||
});
|
||||
test('does not call write if scaleMetricValues is not set', () => {
|
||||
const aggConfigs = createAggConfigs([{ type: 'count' } as any]);
|
||||
|
||||
const writeMock = jest.fn();
|
||||
aggConfigs.getRequestAggs()[0].write = writeMock;
|
||||
|
||||
tabifyAggResponse(aggConfigs, metricOnly, {
|
||||
metricsAtAllLevels: true,
|
||||
});
|
||||
expect(writeMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('does call write if scaleMetricValues is set', () => {
|
||||
const aggConfigs = createAggConfigs([
|
||||
{ type: 'count', params: { scaleMetricValues: true } } as any,
|
||||
]);
|
||||
|
||||
const writeMock = jest.fn(() => ({}));
|
||||
aggConfigs.getRequestAggs()[0].write = writeMock;
|
||||
|
||||
tabifyAggResponse(aggConfigs, metricOnly, {
|
||||
metricsAtAllLevels: true,
|
||||
});
|
||||
expect(writeMock).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('transforms a complex response', () => {
|
||||
let esResp: typeof threeTermBuckets;
|
||||
let aggConfigs: IAggConfigs;
|
||||
|
|
|
@ -37,8 +37,10 @@ export function tabifyAggResponse(
|
|||
|
||||
if (column) {
|
||||
const agg = column.aggConfig;
|
||||
const aggInfo = agg.write(aggs);
|
||||
aggScale *= aggInfo.metricScale || 1;
|
||||
if (agg.getParam('scaleMetricValues')) {
|
||||
const aggInfo = agg.write(aggs);
|
||||
aggScale *= aggInfo.metricScale || 1;
|
||||
}
|
||||
|
||||
switch (agg.type.type) {
|
||||
case AggGroupNames.Buckets:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue