Skip to content

Commit

Permalink
fixing discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Sep 14, 2018
1 parent c8dec37 commit 98c73e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/vis/request_handlers/courier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 5 additions & 6 deletions src/ui/public/vis/response_handlers/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down

0 comments on commit 98c73e5

Please sign in to comment.