Skip to content

Commit

Permalink
Review feedback. Update if/else for readability. Make timestamp diffe…
Browse files Browse the repository at this point in the history
…rences more clear
  • Loading branch information
Aaron Caldwell committed Jan 27, 2021
1 parent 5c0f96d commit 95a8853
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,17 @@ export function getActiveEntriesAndGenerateAlerts(
alertInstanceFactory(alertInstanceId).scheduleActions(ActionGroupId, context);
}
});
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);
return;
}

const otherCatIndex = locationsArr.findIndex(
({ shapeLocationId }) => shapeLocationId === OTHER_CATEGORY
);
if (otherCatIndex >= 0) {
const afterOtherLocationsArr = locationsArr.slice(0, otherCatIndex);
allActiveEntriesMap.set(entityName, afterOtherLocationsArr);
} else {
allActiveEntriesMap.set(entityName, locationsArr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('geo_containment', () => {
{
location: [0, 0],
shapeLocationId: '456',
dateInShape: 'Wed Dec 09 2020 15:31:31 GMT-0700 (Mountain Standard Time)',
dateInShape: 'Wed Dec 16 2020 15:31:31 GMT-0700 (Mountain Standard Time)',
docId: 'docId2',
},
],
Expand All @@ -173,7 +173,7 @@ describe('geo_containment', () => {
{
location: [0, 0],
shapeLocationId: '789',
dateInShape: 'Wed Dec 09 2020 16:31:31 GMT-0700 (Mountain Standard Time)',
dateInShape: 'Wed Dec 23 2020 16:31:31 GMT-0700 (Mountain Standard Time)',
docId: 'docId3',
},
],
Expand Down Expand Up @@ -346,13 +346,13 @@ describe('geo_containment', () => {
{
location: [0, 0],
shapeLocationId: '123',
dateInShape: 'Wed Dec 08 2020 14:31:31 GMT-0700 (Mountain Standard Time)',
dateInShape: 'Wed Dec 08 2020 12:31:31 GMT-0700 (Mountain Standard Time)',
docId: 'docId2',
},
{
location: [0, 0],
shapeLocationId: '456',
dateInShape: 'Wed Dec 07 2020 14:31:31 GMT-0700 (Mountain Standard Time)',
dateInShape: 'Wed Dec 07 2020 10:31:31 GMT-0700 (Mountain Standard Time)',
docId: 'docId3',
},
]);
Expand Down Expand Up @@ -382,13 +382,13 @@ describe('geo_containment', () => {
{
location: [0, 0],
shapeLocationId: '123',
dateInShape: 'Wed Dec 08 2020 14:31:31 GMT-0700 (Mountain Standard Time)',
dateInShape: 'Wed Dec 08 2020 12:31:31 GMT-0700 (Mountain Standard Time)',
docId: 'docId1',
},
{
location: [0, 0],
shapeLocationId: '456',
dateInShape: 'Wed Dec 07 2020 14:31:31 GMT-0700 (Mountain Standard Time)',
dateInShape: 'Wed Dec 07 2020 10:31:31 GMT-0700 (Mountain Standard Time)',
docId: 'docId1',
},
]);
Expand All @@ -415,13 +415,13 @@ describe('geo_containment', () => {
{
location: [0, 0],
shapeLocationId: OTHER_CATEGORY,
dateInShape: 'Wed Dec 08 2020 14:31:31 GMT-0700 (Mountain Standard Time)',
dateInShape: 'Wed Dec 08 2020 12:31:31 GMT-0700 (Mountain Standard Time)',
docId: 'docId1',
},
{
location: [0, 0],
shapeLocationId: '456',
dateInShape: 'Wed Dec 07 2020 14:31:31 GMT-0700 (Mountain Standard Time)',
dateInShape: 'Wed Dec 07 2020 10:31:31 GMT-0700 (Mountain Standard Time)',
docId: 'docId1',
},
]);
Expand Down

0 comments on commit 95a8853

Please sign in to comment.