From 8e1e9b2ec24b23304061e38c6d55c85e8686478c Mon Sep 17 00:00:00 2001 From: Finn Date: Tue, 12 Dec 2017 17:31:05 +0000 Subject: [PATCH] fixed snippets if no values to get --- lib/Pear/LocalLoop/Controller/Api/V1/Customer/Snippets.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Api/V1/Customer/Snippets.pm b/lib/Pear/LocalLoop/Controller/Api/V1/Customer/Snippets.pm index c1846c9..139b796 100644 --- a/lib/Pear/LocalLoop/Controller/Api/V1/Customer/Snippets.pm +++ b/lib/Pear/LocalLoop/Controller/Api/V1/Customer/Snippets.pm @@ -16,9 +16,10 @@ sub index { my $leaderboard_rs = $c->schema->resultset('Leaderboard'); my $monthly_board = $leaderboard_rs->get_latest( 'monthly_total' ); - my $monthly_values = $monthly_board->values; - $data->{ user_position } = $monthly_values ? $monthly_values->find({ entity_id => $entity->id })->position : 0; - + if (defined $monthly_board) { + my $monthly_values = $monthly_board->values; + $data->{ user_position } = $monthly_values ? $monthly_values->find({ entity_id => $entity->id })->position : 0; + } return $c->render( json => { success => Mojo::JSON->true,