Skip to content

Commit

Permalink
Merge pull request #1085: Fix groups resource listing
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlin authored Dec 9, 2024
2 parents 632ab48 + dbf69a6 commit f02d9ea
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions static-site/src/components/ListResources/useDataFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,12 @@ function partitionByPathogen(
versioned: boolean,
) {
return Object.entries(pathVersions).reduce((store: Record<string, Resource[]>, [name, dates]) => {
const sortedDates = [...dates].sort();

const nameParts = name.split('/');

if (nameParts[0] === undefined) {
throw new InternalError(`Name is not properly formatted: '${name}'`);
}

if (sortedDates[0] === undefined) {
throw new InternalError("Resource does not have any dates.");
}

const groupName = nameParts[0];

const resourceDetails: Resource = {
Expand All @@ -83,9 +77,14 @@ function partitionByPathogen(
nameParts,
sortingName: _sortableName(nameParts),
url: `/${pathPrefix}${name}`,
lastUpdated: sortedDates.at(-1),
};
if (versioned) {
const sortedDates = [...dates].sort();
if (sortedDates[0] === undefined) {
throw new InternalError("Resource does not have any dates.");
}

resourceDetails.lastUpdated = sortedDates.at(-1);
resourceDetails.firstUpdated = sortedDates[0];
resourceDetails.dates = sortedDates;
resourceDetails.nVersions = sortedDates.length;
Expand Down

0 comments on commit f02d9ea

Please sign in to comment.