Skip to content

Commit e6903e3

Browse files
author
Aaron Caldwell
committed
Type fixes
1 parent 4f473d3 commit e6903e3

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

  • x-pack/plugins/stack_alerts

x-pack/plugins/stack_alerts/public/alert_types/geo_containment/query_builder/index.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export const GeoContainmentAlertTypeExpression: React.FunctionComponent<
6767
boundaryIndexQuery,
6868
boundaryGeoField,
6969
boundaryNameField,
70-
delayOffsetWithUnits,
7170
} = alertParams;
7271

7372
const [indexPattern, _setIndexPattern] = useState<IIndexPattern>({
@@ -137,7 +136,6 @@ export const GeoContainmentAlertTypeExpression: React.FunctionComponent<
137136
boundaryIndexId: boundaryIndexId ?? DEFAULT_VALUES.BOUNDARY_INDEX_ID,
138137
boundaryGeoField: boundaryGeoField ?? DEFAULT_VALUES.BOUNDARY_GEO_FIELD,
139138
boundaryNameField: boundaryNameField ?? DEFAULT_VALUES.BOUNDARY_NAME_FIELD,
140-
delayOffsetWithUnits: delayOffsetWithUnits ?? DEFAULT_VALUES.DELAY_OFFSET_WITH_UNITS,
141139
});
142140
if (!alertsContext.dataIndexPatterns) {
143141
return;
@@ -150,9 +148,6 @@ export const GeoContainmentAlertTypeExpression: React.FunctionComponent<
150148
const _boundaryIndexPattern = await alertsContext.dataIndexPatterns.get(boundaryIndexId);
151149
setBoundaryIndexPattern(_boundaryIndexPattern);
152150
}
153-
if (delayOffsetWithUnits) {
154-
setDelayOffset(+delayOffsetWithUnits.replace(/\D/g, ''));
155-
}
156151
};
157152
initToDefaultParams();
158153
// eslint-disable-next-line react-hooks/exhaustive-deps

x-pack/plugins/stack_alerts/server/alert_types/geo_containment/geo_containment.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { ActionGroupId, GEO_CONTAINMENT_ID, GeoContainmentParams } from './alert
1414
interface LatestEntityLocation {
1515
location: number[];
1616
shapeLocationId: string;
17-
entityName: string;
1817
dateInShape: string | null;
1918
docId: string;
2019
}
@@ -24,13 +23,11 @@ export function transformResults(
2423
results: SearchResponse<unknown> | undefined,
2524
dateField: string,
2625
geoField: string
27-
): Map<string, EntityLocation> {
26+
): Map<string, LatestEntityLocation> {
2827
if (!results) {
29-
return [];
28+
return new Map();
3029
}
31-
// For the latest of all results, get most recent
3230
const buckets = _.get(results, 'aggregations.shapes.buckets', {});
33-
// @ts-expect-error
3431
const arrResults = _.flatMap(buckets, (bucket: unknown, bucketKey: string) => {
3532
const subBuckets = _.get(bucket, 'entitySplit.buckets', []);
3633
return _.map(subBuckets, (subBucket) => {
@@ -45,7 +42,7 @@ export function transformResults(
4542
.map((coordString) => +coordString)
4643
.reverse()
4744
.value()
48-
: null;
45+
: [];
4946
const dateInShape = _.get(
5047
subBucket,
5148
`entityHits.hits.hits[0].fields["${dateField}"][0]`,
@@ -64,13 +61,19 @@ export function transformResults(
6461
});
6562
const orderedResults = _.orderBy(arrResults, ['entityName', 'dateInShape'], ['asc', 'desc'])
6663
// Get unique
67-
.reduce((accu: Map<string, EntityLocation>, el: LatestEntityLocation) => {
68-
const { entityName, ...locationData } = el;
69-
if (!accu.has(entityName)) {
70-
accu.set(entityName, locationData);
71-
}
72-
return accu;
73-
}, new Map());
64+
.reduce(
65+
(
66+
accu: Map<string, LatestEntityLocation>,
67+
el: LatestEntityLocation & { entityName: string }
68+
) => {
69+
const { entityName, ...locationData } = el;
70+
if (!accu.has(entityName)) {
71+
accu.set(entityName, locationData);
72+
}
73+
return accu;
74+
},
75+
new Map()
76+
);
7477
return orderedResults;
7578
}
7679

@@ -144,7 +147,7 @@ export const getGeoContainmentExecutor = (log: Logger) =>
144147
currentIntervalResults = await executeEsQuery(currIntervalStartTime, currIntervalEndTime);
145148
}
146149

147-
const currLocationMap: Map<string, EntityLocation> = transformResults(
150+
const currLocationMap: Map<string, LatestEntityLocation> = transformResults(
148151
currentIntervalResults,
149152
params.dateField,
150153
params.geoField

0 commit comments

Comments
 (0)