fixed snippets if no values to get

This commit is contained in:
Finn 2017-12-12 17:31:05 +00:00
parent 59dd053b45
commit 8e1e9b2ec2

View file

@ -16,9 +16,10 @@ sub index {
my $leaderboard_rs = $c->schema->resultset('Leaderboard'); my $leaderboard_rs = $c->schema->resultset('Leaderboard');
my $monthly_board = $leaderboard_rs->get_latest( 'monthly_total' ); my $monthly_board = $leaderboard_rs->get_latest( 'monthly_total' );
if (defined $monthly_board) {
my $monthly_values = $monthly_board->values; my $monthly_values = $monthly_board->values;
$data->{ user_position } = $monthly_values ? $monthly_values->find({ entity_id => $entity->id })->position : 0; $data->{ user_position } = $monthly_values ? $monthly_values->find({ entity_id => $entity->id })->position : 0;
}
return $c->render( return $c->render(
json => { json => {
success => Mojo::JSON->true, success => Mojo::JSON->true,