From 9e9abf68a6612f25ef9c9c85645f2e1bf72c9359 Mon Sep 17 00:00:00 2001 From: Jonathan Buttner Date: Wed, 18 Nov 2020 13:59:32 -0500 Subject: [PATCH] Fixing generator start and end time generation --- .../security_solution/common/endpoint/generate_data.test.ts | 6 ++---- .../security_solution/common/endpoint/generate_data.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/security_solution/common/endpoint/generate_data.test.ts b/x-pack/plugins/security_solution/common/endpoint/generate_data.test.ts index ff40bc935b9f..644f1d71e19a 100644 --- a/x-pack/plugins/security_solution/common/endpoint/generate_data.test.ts +++ b/x-pack/plugins/security_solution/common/endpoint/generate_data.test.ts @@ -272,16 +272,14 @@ describe('data generator', () => { let startTime = new Date(timestampSafeVersion(tree.allEvents[0]) ?? startOfEpoch); expect(startTime).not.toEqual(startOfEpoch); let endTime = new Date(timestampSafeVersion(tree.allEvents[0]) ?? startOfEpoch); - expect(startTime).not.toEqual(startOfEpoch); + expect(endTime).not.toEqual(startOfEpoch); for (const event of tree.allEvents) { const currentEventTime = new Date(timestampSafeVersion(event) ?? startOfEpoch); expect(currentEventTime).not.toEqual(startOfEpoch); if (currentEventTime < startTime) { startTime = currentEventTime; - } - - if (currentEventTime > endTime) { + } else { endTime = currentEventTime; } } diff --git a/x-pack/plugins/security_solution/common/endpoint/generate_data.ts b/x-pack/plugins/security_solution/common/endpoint/generate_data.ts index 952a74886d32..de8bd83432d1 100644 --- a/x-pack/plugins/security_solution/common/endpoint/generate_data.ts +++ b/x-pack/plugins/security_solution/common/endpoint/generate_data.ts @@ -726,7 +726,7 @@ export class EndpointDocGenerator { if (eventTimestamp !== undefined) { if (eventTimestamp < startTime) { startTime = eventTimestamp; - } else if (eventTimestamp > endTime) { + } else { endTime = eventTimestamp; } }