Skip to content

Commit

Permalink
Merge pull request #54 from alkem-io/server-4401-make-sure-result-tim…
Browse files Browse the repository at this point in the history
…estamp-is-in-UTC

Make sure the result event timestamp is in UTC timezone
  • Loading branch information
valentinyanakiev authored Sep 3, 2024
2 parents e79b5d9 + 6026ff9 commit 35a294d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alkemio/space-ingest",
"version": "0.9.0",
"version": "0.9.1",
"description": "",
"author": "Alkemio Foundation",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion src/event.bus/events/ingest.space.result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {}
Expand Down
12 changes: 9 additions & 3 deletions src/space.embed/embed.space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};

0 comments on commit 35a294d

Please sign in to comment.