From 4b1699da225e7fb76ebc78c9cb35e3c13ca8207b Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Fri, 17 May 2024 09:28:47 -0600 Subject: [PATCH] Sort saved searches --- pr-status.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pr-status.pl b/pr-status.pl index 8cbb667..52400eb 100755 --- a/pr-status.pl +++ b/pr-status.pl @@ -55,10 +55,14 @@ sub save_search { @$searches, { pull_request => $r->{pull_request}, - title => $r->{title} + title => $r->{title}, + epoch => time } ) unless grep { $r->{pull_request} == $_->{pull_request} } @$searches; + my @sorted = reverse sort { $a->{epoch} <=> $b->{epoch} } @$searches; + $searches = \@sorted; + open my $fh, ">", "${work_dir}/searches.json" or die $!; print $fh encode_json($searches); close $fh; @@ -70,6 +74,8 @@ sub load_searches { $searches = decode_json <$fh>; close $fh; } + my @sorted = reverse sort { $a->{epoch} <=> $b->{epoch} } @$searches; + $searches = \@sorted; } sub get_commit { @@ -214,6 +220,9 @@ get '/:pr' => sub ($c) { my ( $release, $status ) = figure_status($list); + my @sorted = reverse sort { $a->{epoch} <=> $b->{epoch} } @$searches; + $searches = \@sorted; + my $result = { title => $title, branches => $list,