Skip to content
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
2 changes: 2 additions & 0 deletions src/platform/plugins/private/vis_types/vega/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ dependsOn:
- '@kbn/ui-actions-plugin'
- '@kbn/css-utils'
- '@kbn/visualizations-common'
- '@kbn/es-types'
- '@kbn/esql-utils'
tags:
- plugin
- prod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type {
Query,
ContextVarsObject,
} from './types';
import { CONTEXT, getRequestName, TIMEFIELD } from './parser_utils';

const TIMEFILTER: string = '%timefilter%';
const AUTOINTERVAL: string = '%autointerval%';
Expand All @@ -34,15 +35,6 @@ const FILTER_CLAUSE: string = '%dashboard_context-filter_clause%';

// These values may appear in the 'url': { ... } object
const LEGACY_CONTEXT: string = '%context_query%';
const CONTEXT: string = '%context%';
const TIMEFIELD: string = '%timefield%';

const getRequestName = (request: EsQueryRequest, index: number) =>
request.dataObject.name ||
i18n.translate('visTypeVega.esQueryParser.unnamedRequest', {
defaultMessage: 'Unnamed request #{index}',
values: { index },
});

/**
* This class parses ES requests specified in the data.url objects.
Expand Down Expand Up @@ -207,15 +199,17 @@ export class EsQueryParser {
async populateData(requests: EsQueryRequest[]) {
const esSearches = requests.map((r: EsQueryRequest, index: number) => ({
...r.url,
name: getRequestName(r, index),
name: getRequestName(r.dataObject.name, index),
}));

const data$ = this._searchAPI.search(esSearches);

const results = await data$.toPromise();

results.forEach((data, index) => {
const requestObject = requests.find((item) => getRequestName(item, index) === data.name);
const requestObject = requests.find(
(item) => getRequestName(item.dataObject.name, index) === data.name
);

if (requestObject) {
requestObject.dataObject.url = requestObject.url;
Expand Down
Loading