From 6026ff94d19010107901d14fe94acbb35d2acce2 Mon Sep 17 00:00:00 2001 From: Vladimir Aleksiev Date: Mon, 2 Sep 2024 18:48:32 +0300 Subject: [PATCH] make sure the result event timestamp is in UTC timezone --- package.json | 2 +- src/event.bus/events/ingest.space.result.ts | 2 +- src/space.embed/embed.space.ts | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 307116c..f760f01 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@alkemio/space-ingest", - "version": "0.9.0", + "version": "0.9.1", "description": "", "author": "Alkemio Foundation", "private": true, diff --git a/src/event.bus/events/ingest.space.result.ts b/src/event.bus/events/ingest.space.result.ts index b569d1d..51b88ab 100644 --- a/src/event.bus/events/ingest.space.result.ts +++ b/src/event.bus/events/ingest.space.result.ts @@ -19,7 +19,7 @@ export class IngestSpaceResult { public readonly spaceId: string, public readonly purpose: SpaceIngestionPurpose, public readonly personaServiceId: string, - public readonly timestamp: number, + public timestamp?: number, public result: SpaceIngestionResult = SpaceIngestionResult.SUCCESS, public error?: IngestError ) {} diff --git a/src/space.embed/embed.space.ts b/src/space.embed/embed.space.ts index 3492164..d329e7a 100644 --- a/src/space.embed/embed.space.ts +++ b/src/space.embed/embed.space.ts @@ -20,14 +20,17 @@ const setResultError = ( ) => { result.error = { code, message }; result.result = SpaceIngestionResult.FAILURE; + // this shenanigan is here to ensure the Timestamp is in UTC timezone + result.timestamp = new Date( + new Date().toLocaleString('en', { timeZone: 'UTC' }) + ).getTime(); return result; }; export const embedSpace = async (event: IngestSpace) => { const resultEvent = new IngestSpaceResult( event.spaceId, event.purpose, - event.personaServiceId, - Date.now() + event.personaServiceId ); const spaceId = event.spaceId; @@ -85,6 +88,9 @@ export const embedSpace = async (event: IngestSpace) => { message: 'An error occured while embedding.', }; } - + // this shenanigan is here to ensure the Timestamp is in UTC timezone + resultEvent.timestamp = new Date( + new Date().toLocaleString('en', { timeZone: 'UTC' }) + ).getTime(); return resultEvent; };