fixed snippets if no values to get

This commit is contained in:
Finn 2017-12-12 17:31:05 +00:00
parent 5049fa9eed
commit 536ab21551

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' );
my $monthly_values = $monthly_board->values; if (defined $monthly_board) {
$data->{ user_position } = $monthly_values ? $monthly_values->find({ entity_id => $entity->id })->position : 0; my $monthly_values = $monthly_board->values;
$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,