Skip to content

Commit

Permalink
generate-index-json: Sort apps based on the last update's timestamp (#53
Browse files Browse the repository at this point in the history
)

Place recently updated applications higher in the list.
  • Loading branch information
FilipZajdel authored Nov 13, 2024
1 parent a6a6eb1 commit f13fa69
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/generate-index-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ async function generateIndex(orgIndices: ParsedOrgFile[]): Promise<AppIndex> {
}

appIndex.apps = appIndex.apps.sort((a, b) => {
if (a.stars === b.stars) {
const [updatedA, updatedB] = [
new Date(a.lastUpdate),
new Date(b.lastUpdate)
];

if (updatedA === updatedB) {
return a.name < b.name ? -1 : 1;
}

return a.stars > b.stars ? -1 : 1;
return updatedA > updatedB ? -1 : 1;
});

return appIndex;
Expand Down

0 comments on commit f13fa69

Please sign in to comment.