Fixing attributes wrong ordering.

This commit is contained in:
Sergiotarxz 2023-09-17 05:56:37 +02:00
parent dc807cdc60
commit a848f67606

View File

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