Skip to content

Commit

Permalink
fix(egressRecord): Remove unnecessary multiplication for ts conversion (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
fforbeck authored Nov 22, 2024
1 parent 5b43e41 commit b7bc90e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/capabilities/src/space.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/upload-api/src/space/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit b7bc90e

Please sign in to comment.