From 98c73e5690d663405ccd7074e329fba820c43731 Mon Sep 17 00:00:00 2001 From: ppisljar Date: Fri, 14 Sep 2018 14:58:59 +0200 Subject: [PATCH] fixing discovery --- .../kibana/public/discover/controllers/discover.js | 4 +++- src/ui/public/vis/request_handlers/courier.js | 2 +- src/ui/public/vis/response_handlers/legacy.js | 11 +++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index 8732e0d4ec3eb..f62ea2794d386 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -58,6 +58,7 @@ import { getUnhashableStatesProvider } from 'ui/state_management/state_hashing'; import { Inspector } from 'ui/inspector'; import { RequestAdapter } from 'ui/inspector/adapters'; import { getRequestInspectorStats, getResponseInspectorStats } from 'ui/courier/utils/courier_inspector_utils'; +import { tabifyAggResponse } from 'ui/agg_response/tabify'; const app = uiModules.get('apps/discover', [ 'kibana/notify', @@ -626,9 +627,10 @@ function discoverController( $scope.mergedEsResp = merged; if ($scope.opts.timefield) { + const tabifiedData = tabifyAggResponse($scope.vis.aggs, merged); $scope.searchSource.rawResponse = merged; Promise - .resolve(responseHandler($scope.vis, merged)) + .resolve(responseHandler(tabifiedData)) .then(resp => { $scope.visData = resp; const visEl = $element.find('#discoverHistogram')[0]; diff --git a/src/ui/public/vis/request_handlers/courier.js b/src/ui/public/vis/request_handlers/courier.js index 69019df2ca6f9..d9df5f1717a80 100644 --- a/src/ui/public/vis/request_handlers/courier.js +++ b/src/ui/public/vis/request_handlers/courier.js @@ -157,7 +157,7 @@ const CourierRequestHandlerProvider = function () { const parsedTimeRange = getTime(aggs.indexPattern, timeRange); - searchSource.tabifiedResponse = tabifyAggResponse(aggs, resp, { + searchSource.tabifiedResponse = tabifyAggResponse(vis.getAggConfig(), resp, { metricsAtAllLevels: vis.isHierarchical(), partialRows, timeRange: parsedTimeRange ? parsedTimeRange.range : undefined, diff --git a/src/ui/public/vis/response_handlers/legacy.js b/src/ui/public/vis/response_handlers/legacy.js index 697d21f59b03e..7f5c130dc254a 100644 --- a/src/ui/public/vis/response_handlers/legacy.js +++ b/src/ui/public/vis/response_handlers/legacy.js @@ -21,7 +21,6 @@ import _ from 'lodash'; import AggConfigResult from '../../vis/agg_config_result'; import { VisResponseHandlersRegistryProvider } from '../../registry/vis_response_handlers'; - const LegacyResponseHandlerProvider = function () { return { @@ -31,12 +30,12 @@ const LegacyResponseHandlerProvider = function () { const converted = { tables: [] }; // check if there are buckets after the first metric - const metricsAtAllLevels = table.columns.findIndex(column => column.aggConfig.type.type === 'metrics') < - _.findLastIndex(table.columns, column => column.aggConfig.type.type === 'buckets'); + const metricsAtAllLevels = table.columns.findIndex(column => _.get(column, 'aggConfig.type.type') === 'metrics') < + _.findLastIndex(table.columns, column => _.get(column, 'aggConfig.type.type') === 'buckets'); - const splitColumn = table.columns.find(column => column.aggConfig.schema.name === 'split'); - const numberOfMetrics = table.columns.filter(column => column.aggConfig.type.type === 'metrics').length; - const numberOfBuckets = table.columns.filter(column => column.aggConfig.type.type === 'buckets').length; + const splitColumn = table.columns.find(column => _.get(column, 'aggConfig.schema.name') === 'split'); + const numberOfMetrics = table.columns.filter(column => _.get(column, 'aggConfig.type.type') === 'metrics').length; + const numberOfBuckets = table.columns.filter(column => _.get(column, 'aggConfig.type.type') === 'buckets').length; const metricsPerBucket = numberOfMetrics / numberOfBuckets; if (splitColumn) {