summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Releases
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2022-06-26 11:11:07 +0200
committerYorhel <git@yorhel.nl>2022-06-26 11:11:09 +0200
commit055e526a9a0e8cdb54285eec0441c5a04b1281e4 (patch)
treeeb2248acf2b3141ce952747c14e029ca0c17af9d /lib/VNWeb/Releases
parent3bf09a32b66cce0f02c5f7245b0a4afbb77e5db1 (diff)
Fix ordering of patch releases + releases list on producer pages
Fixes https://vndb.org/t950.1289 and https://vndb.org/t950.1290
Diffstat (limited to 'lib/VNWeb/Releases')
-rw-r--r--lib/VNWeb/Releases/Lib.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/VNWeb/Releases/Lib.pm b/lib/VNWeb/Releases/Lib.pm
index f6c20240..20432c42 100644
--- a/lib/VNWeb/Releases/Lib.pm
+++ b/lib/VNWeb/Releases/Lib.pm
@@ -3,7 +3,7 @@ package VNWeb::Releases::Lib;
use VNWeb::Prelude;
use Exporter 'import';
-our @EXPORT = qw/enrich_release_elm releases_by_vn enrich_release release_row_/;
+our @EXPORT = qw/enrich_release_elm releases_by_vn enrich_release sort_releases release_row_/;
# Enrich a list of releases so that it's suitable as 'Releases' Elm response.
@@ -39,6 +39,21 @@ sub enrich_release {
}
+# Sort an array of releases, assumes the objects come from enrich_release()
+# (Not always possible with an SQL ORDER BY due to rtype being context-dependent and platforms coming from other tables)
+sub sort_releases {
+ return [ sort {
+ $a->{released} <=> $b->{released} ||
+ $b->{rtype} cmp $a->{rtype} ||
+ $b->{official} cmp $a->{official} ||
+ $a->{patch} cmp $b->{patch} ||
+ ($a->{platforms}[0]||'') cmp ($b->{platforms}[0]||'') ||
+ $a->{title} cmp $b->{title} ||
+ idcmp($a->{id}, $b->{id})
+ } $_[0]->@* ];
+}
+
+
sub release_extlinks_ {
my($r, $id) = @_;
return if !$r->{extlinks}->@*;