Fixing attributes wrong ordering.

This commit is contained in:
Sergiotarxz 2023-09-17 05:56:37 +02:00
parent dc807cdc60
commit a848f67606
1 changed files with 2 additions and 3 deletions

View File

@ -186,10 +186,9 @@ sub RetrieveAllPostsForCategory ( $self, $category_name ) {
sub shufflePostsIfRequired ( $self, $category, $posts ) {
my $pinned_posts = [
sort { $b->{pinned} <=> $b->{pinned} }
grep { exists $_->{pinned} } @$posts
grep { defined $_->{pinned} } @$posts
];
$posts = [ grep { !exists $_->{pinned} } @$posts ];
$pinned_posts = [ sort { $b <=> $a } @$pinned_posts ];
if ( exists $category->{random} && $category->{random} ) {
require List::AllUtils;
$posts = [ List::AllUtils::shuffle @$posts ];
@ -206,7 +205,7 @@ sub RetrieveDirectPostsForCategory ( $self, $category_name ) {
}
my $posts = $post_by_category->{$category_name};
$posts //= [];
return [@$posts];
return $self->shufflePostsIfRequired($category, [@$posts]);
}
sub PreviewOg {