Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export const GeoThresholdAlertTypeExpression: React.FunctionComponent<AlertTypeP
}
fullWidth
onChange={(e) => setAlertParams('trackingEvent', e.target.value)}
options={[conditionOptions[0]]} // TODO: Make all options avab. before merge
options={conditionOptions}
/>
</div>
</EuiFormRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
export enum TrackingEvent {
entered = 'entered',
exited = 'exited',
crossed = 'crossed',
}

export interface GeoThresholdAlertParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,14 @@ export function getMovedEntities(
[]
)
// Do not track entries to or exits from 'other'
.filter((entityMovementDescriptor: EntityMovementDescriptor) =>
trackingEvent === 'entered'
? entityMovementDescriptor.currLocation.shapeId !== OTHER_CATEGORY
: entityMovementDescriptor.prevLocation.shapeId !== OTHER_CATEGORY
)
.filter((entityMovementDescriptor: EntityMovementDescriptor) => {
if (trackingEvent !== 'crossed') {
return trackingEvent === 'entered'
? entityMovementDescriptor.currLocation.shapeId !== OTHER_CATEGORY
: entityMovementDescriptor.prevLocation.shapeId !== OTHER_CATEGORY;
}
return true;
})
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ describe('geo_threshold', () => {
});

describe('getMovedEntities', () => {
const trackingEvent = 'entered';
it('should return empty array if only movements were within same shapes', async () => {
const currLocationArr = [
{
Expand Down Expand Up @@ -92,7 +91,7 @@ describe('geo_threshold', () => {
shapeLocationId: 'sameShape2',
},
];
const movedEntities = getMovedEntities(currLocationArr, prevLocationArr, trackingEvent);
const movedEntities = getMovedEntities(currLocationArr, prevLocationArr, 'entered');
expect(movedEntities).toEqual([]);
});

Expand Down Expand Up @@ -129,7 +128,7 @@ describe('geo_threshold', () => {
shapeLocationId: 'thisOneDidntMove',
},
];
const movedEntities = getMovedEntities(currLocationArr, prevLocationArr, trackingEvent);
const movedEntities = getMovedEntities(currLocationArr, prevLocationArr, 'entered');
expect(movedEntities.length).toEqual(1);
});

Expand All @@ -152,7 +151,7 @@ describe('geo_threshold', () => {
shapeLocationId: 'oldShapeLocation',
},
];
const movedEntities = getMovedEntities(currLocationArr, prevLocationArr, trackingEvent);
const movedEntities = getMovedEntities(currLocationArr, prevLocationArr, 'entered');
expect(movedEntities).toEqual([]);
});

Expand All @@ -178,5 +177,51 @@ describe('geo_threshold', () => {
const movedEntities = getMovedEntities(currLocationArr, prevLocationArr, 'exited');
expect(movedEntities).toEqual([]);
});

it('should not ignore "crossed" results from "other"', async () => {
const currLocationArr = [
{
dateInShape: '2020-09-28T18:01:41.190Z',
docId: 'N-ng1XQB6yyY-xQxnGSM',
entityName: '936',
location: [-82.8814151789993, 41.62806099653244],
shapeLocationId: 'newShapeLocation',
},
];
const prevLocationArr = [
{
dateInShape: '2020-08-28T18:01:41.190Z',
docId: 'N-ng1XQB6yyY-xQxnGSM',
entityName: '936',
location: [-82.8814151789993, 40.62806099653244],
shapeLocationId: OTHER_CATEGORY,
},
];
const movedEntities = getMovedEntities(currLocationArr, prevLocationArr, 'crossed');
expect(movedEntities.length).toEqual(1);
});

it('should not ignore "crossed" results to "other"', async () => {
const currLocationArr = [
{
dateInShape: '2020-08-28T18:01:41.190Z',
docId: 'N-ng1XQB6yyY-xQxnGSM',
entityName: '936',
location: [-82.8814151789993, 40.62806099653244],
shapeLocationId: OTHER_CATEGORY,
},
];
const prevLocationArr = [
{
dateInShape: '2020-09-28T18:01:41.190Z',
docId: 'N-ng1XQB6yyY-xQxnGSM',
entityName: '936',
location: [-82.8814151789993, 41.62806099653244],
shapeLocationId: 'newShapeLocation',
},
];
const movedEntities = getMovedEntities(currLocationArr, prevLocationArr, 'crossed');
expect(movedEntities.length).toEqual(1);
});
});
});