From b7bc90e6a33b8f33dd7356794c55a77b364799ee Mon Sep 17 00:00:00 2001 From: Felipe Forbeck Date: Fri, 22 Nov 2024 17:31:49 -0300 Subject: [PATCH] fix(egressRecord): Remove unnecessary multiplication for ts conversion (#1588) ### Context This PR fixes the handling of the `servedAt` timestamp in the `packages/upload-api/src/space/record.js` file. The previous implementation included a multiplication by 1000, assuming a conversion from seconds to milliseconds was necessary. This change removes the conversion. --- packages/capabilities/src/space.js | 2 +- packages/upload-api/src/space/record.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/capabilities/src/space.js b/packages/capabilities/src/space.js index 54f48cb7c..0f638d3d6 100644 --- a/packages/capabilities/src/space.js +++ b/packages/capabilities/src/space.js @@ -87,7 +87,7 @@ export const egressRecord = capability({ resource: Schema.link(), /** Amount of bytes served. */ bytes: Schema.integer().greaterThan(0), - /** Timestamp of the event in seconds after Unix epoch. */ + /** Timestamp of the event in milliseconds after Unix epoch. */ servedAt: Schema.integer().greaterThan(-1), }), derives: equalWith, diff --git a/packages/upload-api/src/space/record.js b/packages/upload-api/src/space/record.js index 616844d82..17c0ccd74 100644 --- a/packages/upload-api/src/space/record.js +++ b/packages/upload-api/src/space/record.js @@ -33,7 +33,7 @@ const egressRecord = async ({ capability, invocation }, context) => { // Number of bytes that were served. capability.nb.bytes, // Date and time when the resource was served. - new Date(capability.nb.servedAt * 1000), + new Date(capability.nb.servedAt), // Link to the invocation that caused the egress traffic. invocation.cid )