From 105c9093b836e4a363961de79bf1ddd6b705e5ab Mon Sep 17 00:00:00 2001 From: Finn Date: Fri, 10 Nov 2017 18:39:00 +0000 Subject: [PATCH] fixes --- lib/Pear/LocalLoop/Controller/Api/Stats.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Api/Stats.pm b/lib/Pear/LocalLoop/Controller/Api/Stats.pm index 6081f3e..ad984e2 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Stats.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Stats.pm @@ -128,15 +128,15 @@ sub post_leaderboards_paged { if ( !defined $validation->param('page') || $validation->param('page') < 1 ) { my $user_position = $today_board->values->find({ entity_id => $c->stash->{api_user}->entity->id }); - if { $user_position > 10 ) { - int($user_position / 10) + 1 = $page; - } + $page = int(defined $user_position ? $user_position->{position} : 0 / 10) + 1; + } else { + $page = $validation->param('page'); } my $today_values = $today_board->values->search( {}, { - page => $validation->param('page') || $page, + page => $page, rows => 10, order_by => { -asc => 'me.position' }, columns => [ @@ -169,8 +169,8 @@ sub post_leaderboards_paged { success => Mojo::JSON->true, leaderboard => [ @leaderboard_array ], user_position => defined $current_user_position ? $current_user_position->{position} : 0, - page => $validation->param('page') || $page, - page_no => $today_values->pager->total_entries, + page => $page, + count => $today_values->pager->total_entries, }); }