Sort saved searches

This commit is contained in:
Aaron Bieber 2024-05-17 09:28:47 -06:00
parent b15743385f
commit 4b1699da22
No known key found for this signature in database

View File

@ -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,