Skip to content

Commit fc0f8e8

Browse files
authored
Merge pull request #301 from bcgov/SC3864
Add lastModifiedDate from version to the object response
2 parents 9156992 + fd4d5c5 commit fc0f8e8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

app/src/docs/v1.api-spec.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,14 @@ paths:
466466
- $ref: "#/components/schemas/DB-Object"
467467
- type: object
468468
properties:
469+
lastModifiedDate:
470+
type: string
471+
format: date-time
472+
description: >-
473+
The object creation date or the last modified date (as exposed
474+
by S3's `Last-Modified` header), whichever is the latest.
475+
example: "2022-03-11T23:19:16.343Z"
476+
default: null
469477
permissions:
470478
type: array
471479
description: >-

app/src/services/object.js

+7
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ const service = {
174174
.map(o => o.permCode);
175175
}
176176
}
177+
if (Array.isArray(version) && version.length > 0) {
178+
const latestVersion = version.find(v => v.isLatest);
179+
180+
object.lastModifiedDate =
181+
latestVersion.lastModifiedDate ?? latestVersion.createdAt ?? latestVersion.updatedAt;
182+
}
183+
177184
return object;
178185
}).filter(x => x) // Drop empty row results from the array set
179186
);

0 commit comments

Comments
 (0)