Skip to content

Commit

Permalink
[Maps] fix Maps should display better error message instead of EsErro…
Browse files Browse the repository at this point in the history
…r when there is no data for tracks data source (#88847)
  • Loading branch information
nreese authored Jan 20, 2021
1 parent edb338a commit f0f192c
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import React from 'react';

import { GeoJsonProperties } from 'geojson';
import { i18n } from '@kbn/i18n';
import { FIELD_ORIGIN, SOURCE_TYPES, VECTOR_SHAPE_TYPE } from '../../../../common/constants';
import {
EMPTY_FEATURE_COLLECTION,
FIELD_ORIGIN,
SOURCE_TYPES,
VECTOR_SHAPE_TYPE,
} from '../../../../common/constants';
import { getField, addFieldToDSL } from '../../../../common/elasticsearch_util';
import {
ESGeoLineSourceDescriptor,
Expand Down Expand Up @@ -216,6 +221,18 @@ export class ESGeoLineSource extends AbstractESAggSource {
);
const totalEntities = _.get(entityResp, 'aggregations.totalEntities.value', 0);
const areEntitiesTrimmed = entityBuckets.length >= MAX_TRACKS;
if (totalEntities === 0) {
return {
data: EMPTY_FEATURE_COLLECTION,
meta: {
areResultsTrimmed: false,
areEntitiesTrimmed: false,
entityCount: 0,
numTrimmedTracks: 0,
totalEntities: 0,
} as ESGeoLineSourceResponseMeta,
};
}

//
// Fetch tracks
Expand Down

0 comments on commit f0f192c

Please sign in to comment.