aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-06-13 21:25:36 +0000
committerNicolas Vigier <boklm@mageia.org>2013-06-13 21:25:36 +0000
commit89134371188781298679c98fe0cc4da86a0c8b36 (patch)
treeb79f5feb2f0c5b1ce44275b3ef2fed811f02906f /lib
parent23a41e0e089b65cf2223a846abc545a649c3efb1 (diff)
downloadmgaadvisories-89134371188781298679c98fe0cc4da86a0c8b36.tar
mgaadvisories-89134371188781298679c98fe0cc4da86a0c8b36.tar.gz
mgaadvisories-89134371188781298679c98fe0cc4da86a0c8b36.tar.bz2
mgaadvisories-89134371188781298679c98fe0cc4da86a0c8b36.tar.xz
mgaadvisories-89134371188781298679c98fe0cc4da86a0c8b36.zip
Sort advisories by publish time and ID
Diffstat (limited to 'lib')
-rw-r--r--lib/MGA/Advisories.pm15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index 9146242..398f9af 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -118,6 +118,15 @@ sub publish_advisories {
}
}
+sub adv_sort {
+ my $advdb = shift;
+ sort {
+ my $pa = $advdb->{advisories}{$a}{status}{published};
+ my $pb = $advdb->{advisories}{$b}{status}{published};
+ return $pa == $pb ? $b cmp $a : $pb cmp $pa;
+ } @_;
+}
+
sub sort_advisories {
my ($advdb) = @_;
foreach my $adv (keys %{$advdb->{advisories}}) {
@@ -138,6 +147,12 @@ sub sort_advisories {
}
}
}
+ foreach my $by ('by_type', 'by_cve', 'by_rel', 'by_media', 'by_src') {
+ foreach my $k (keys %{$advdb->{$by}}) {
+ $advdb->{$by}{$k} = [ adv_sort($advdb, @{$advdb->{$by}{$k}}) ];
+ }
+ }
+ $advdb->{sorted} = [ adv_sort($advdb, keys $advdb->{advisories}) ];
}
sub process_template {