From 523de586980c9aa840e5fc701013340ef225081a Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Fri, 2 Oct 2020 01:03:30 -0600 Subject: [PATCH] Handle sorting manually vs. using lodash --- .../alert_types/geo_threshold/geo_threshold.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/alerting_builtins/server/alert_types/geo_threshold/geo_threshold.ts b/x-pack/plugins/alerting_builtins/server/alert_types/geo_threshold/geo_threshold.ts index 2b6bde4e11741..65ec3f91f051f 100644 --- a/x-pack/plugins/alerting_builtins/server/alert_types/geo_threshold/geo_threshold.ts +++ b/x-pack/plugins/alerting_builtins/server/alert_types/geo_threshold/geo_threshold.ts @@ -65,7 +65,12 @@ export function transformResults( }); }) .orderBy(['entityName', 'dateInShape'], ['asc', 'desc']) - .sortedUniqBy('entityName') + .reduce((accu, el) => { + if (!accu.length || el.entityName !== accu[accu.length - 1].entityName) { + accu.push(el); + } + return accu; + }, []) .value() ); } @@ -288,7 +293,12 @@ export const getGeoThresholdExecutor = ({ logger: log }: { logger: Logger }) => const prevLocationArr = _.chain(currLocationArr) .concat(state.prevLocationArr) .orderBy(['entityName', 'dateInShape'], ['asc', 'desc']) - .sortedUniqBy('entityName') + .reduce((accu, el) => { + if (!accu.length || el.entityName !== accu[accu.length - 1].entityName) { + accu.push(el); + } + return accu; + }, []) .value(); return {