Skip to content

Commit

Permalink
Fix collection date span and total size
Browse files Browse the repository at this point in the history
  • Loading branch information
siiptuo committed Nov 20, 2024
1 parent 4bdda8e commit 25c428c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions backend/src/routes/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export class CollectionRoutes {
[collection.uuid],
),
]);
return parseInt(regularFiles[0].size) + parseInt(modelFiles[0].size);
return parseInt(regularFiles[0].size || 0) + parseInt(modelFiles[0].size || 0);
}

private async getDateRange(collection: Collection) {
Expand All @@ -312,10 +312,11 @@ export class CollectionRoutes {
[collection.uuid],
),
]);
const startDates = [regularFiles[0].startDate, modelFiles[0].startDate].filter((date) => date != null).sort();
const endDates = [regularFiles[0].endDate, modelFiles[0].endDate].filter((date) => date != null).sort();
return {
startDate:
regularFiles[0].startDate < modelFiles[0].startDate ? regularFiles[0].startDate : modelFiles[0].startDate,
endDate: regularFiles[0].endDate < modelFiles[0].endDate ? regularFiles[0].endDate : modelFiles[0].endDate,
startDate: startDates[0],
endDate: endDates[endDates.length - 1],
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`GET /api/collection/:uuid returns a valid collection 1`] = `
{
"createdAt": "2020-09-28T12:45:21.916Z",
"endDate": "2014-12-05",
"endDate": "2019-09-01",
"files": 2,
"pid": "",
"products": [
Expand Down

0 comments on commit 25c428c

Please sign in to comment.