[Maps] fix Maps should display better error message instead of EsError when there is no data for tracks data source (#88847)

This commit is contained in:
Nathan Reese 2021-01-20 11:25:48 -07:00 committed by GitHub
parent edb338a8ad
commit f0f192c654
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,
@ -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