From 4aa8f214fb78035ad58616de58f7cbc924f6ec6b Mon Sep 17 00:00:00 2001 From: Corwin Smith Date: Thu, 15 Dec 2022 08:27:49 -0700 Subject: [PATCH] [sorting] releases should be sorted by date, then by type (Geth, then Geth + tools) (#158) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * create constant for number of releases per os * sort releases * Apply suggestions from code review * change requests * fix build error * cleanup * fix: typo & prettier * refactor sort function * cleanup unnecessary changes * fix: getReleaseArch case * fix sort * prettier Co-authored-by: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Co-authored-by: Nicolás Quiroz --- src/utils/compareReleasesFn.ts | 15 ++++++++++----- src/utils/getReleaseArch.ts | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/utils/compareReleasesFn.ts b/src/utils/compareReleasesFn.ts index fa2f2b02ef..d0c2ee8dff 100644 --- a/src/utils/compareReleasesFn.ts +++ b/src/utils/compareReleasesFn.ts @@ -1,13 +1,18 @@ import { ReleaseData } from '../types'; export const compareReleasesFn = (a: ReleaseData, b: ReleaseData) => { - if (new Date(a.published) > new Date(b.published)) { - return -1; + const aPublished = new Date(a.published); + const bPublished = new Date(b.published); + const sameDate = aPublished.toDateString() === bPublished.toDateString(); + const sameCommit = a.commit.label === b.commit.label; + + if (sameDate && !sameCommit) { + return aPublished > bPublished ? -1 : 1; } - if (new Date(a.published) < new Date(b.published)) { - return 1; + if (sameDate) { + return a.release.label.length - b.release.label.length; } - return 0; + return aPublished > bPublished ? -1 : 1; }; diff --git a/src/utils/getReleaseArch.ts b/src/utils/getReleaseArch.ts index a2633bed0a..6e947cd7b9 100644 --- a/src/utils/getReleaseArch.ts +++ b/src/utils/getReleaseArch.ts @@ -20,7 +20,7 @@ export const getReleaseArch = (filename: string) => { return 'MIPS32(le)'; case 'mips64': return 'MIPS64'; - case 'MIPS64(le)': + case 'mips64le': return 'MIPS64(le)'; default: return 'all';