From 50e06981d75eb0b2e95d983c31b9e5238ca6653a Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Thu, 20 Jul 2017 17:41:59 +0100 Subject: [PATCH] Fix issue with undefined leaderboard --- lib/Pear/LocalLoop/Controller/Api/Stats.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Pear/LocalLoop/Controller/Api/Stats.pm b/lib/Pear/LocalLoop/Controller/Api/Stats.pm index 496e25d..c6b1c7d 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Stats.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Stats.pm @@ -39,7 +39,8 @@ sub post_index { my $leaderboard_rs = $c->schema->resultset('Leaderboard'); my $monthly_board = $leaderboard_rs->get_latest( 'monthly_total' ); - my $current_user_position = $monthly_board->values->find({ user_id => $c->stash->{api_user}->id }); + my $monthly_values = $monthly_board->values; + my $current_user_position = $monthly_values ? $monthly_values->find({ user_id => $c->stash->{api_user}->id }) : undef; return $c->render( json => { success => Mojo::JSON->true,