Skip to content

Commit

Permalink
Cover case where 'other' and earlier entries are removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Jan 25, 2021
1 parent cb24ca6 commit 1708cef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,17 @@ export function getActiveEntriesAndGenerateAlerts(
alertInstanceFactory(alertInstanceId).scheduleActions(ActionGroupId, context);
}
});
// If the latest location is "other", don't carry it through to the next interval
let otherIndex;
if (locationsArr[0].shapeLocationId === OTHER_CATEGORY) {
allActiveEntriesMap.delete(entityName);
} else if (
locationsArr.some(({ shapeLocationId }, index) => {
otherIndex = index;
return shapeLocationId === OTHER_CATEGORY;
})
) {
const afterOtherLocationsArr = locationsArr.slice(0, otherIndex);
allActiveEntriesMap.set(entityName, afterOtherLocationsArr);
} else {
allActiveEntriesMap.set(entityName, locationsArr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ describe('geo_containment', () => {
expect(allActiveEntriesMap).toEqual(currLocationMap);
});

it('should return entity as active entry if "other" not the latest location', () => {
it('should return entity as active entry if "other" not the latest location but remove "other" and earlier entries', () => {
const emptyPrevLocationMap = new Map();
const currLocationMapWithOther = new Map([...currLocationMap]).set('d', [
{
Expand Down Expand Up @@ -432,7 +432,16 @@ describe('geo_containment', () => {
emptyShapesIdsNamesMap,
currentDateTime
);
expect(allActiveEntriesMap).toEqual(currLocationMapWithOther);
expect(allActiveEntriesMap).toEqual(
new Map([...currLocationMap]).set('d', [
{
location: [0, 0],
shapeLocationId: '123',
dateInShape: 'Wed Dec 10 2020 14:31:31 GMT-0700 (Mountain Standard Time)',
docId: 'docId1',
},
])
);
});
});
});

0 comments on commit 1708cef

Please sign in to comment.