[sorting] releases should be sorted by date, then by type (Geth, then Geth + tools) (#158)

* 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 <nh.quiroz@gmail.com>
This commit is contained in:
Corwin Smith 2022-12-15 08:27:49 -07:00 committed by GitHub
parent 63bbde1747
commit 4aa8f214fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View file

@ -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;
};

View file

@ -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';