Fix calculation mistake on leadearboard display

This commit is contained in:
Tom Bloor 2017-09-15 12:54:36 +01:00
parent 82b71360de
commit 25511ced69
2 changed files with 14 additions and 9 deletions

View file

@ -92,7 +92,12 @@ sub post_leaderboards {
my @leaderboard_array = $today_values->all; my @leaderboard_array = $today_values->all;
if ( $validation->param('type') =~ /total$/ ) { if ( $validation->param('type') =~ /total$/ ) {
map { $_->{value} / 100000 } @leaderboard_array; @leaderboard_array = (map {
{
%$_,
value => $_->{value} / 100000,
}
} @leaderboard_array);
} }
my $current_user_position = $today_values->find({ entity_id => $c->stash->{api_user}->entity->id }); my $current_user_position = $today_values->find({ entity_id => $c->stash->{api_user}->entity->id });

View file

@ -80,13 +80,13 @@ my $now = DateTime->today();
$user_result->create_related( 'purchases', { $user_result->create_related( 'purchases', {
seller_id => $org_result->id, seller_id => $org_result->id,
value => 1, value => 100000,
proof_image => 'a', proof_image => 'a',
}); });
$user_result->create_related( 'purchases', { $user_result->create_related( 'purchases', {
seller_id => $org_result->id, seller_id => $org_result->id,
value => 9, value => 900000,
proof_image => 'a', proof_image => 'a',
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )), purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
}); });
@ -97,13 +97,13 @@ my $now = DateTime->today();
$user_result->create_related( 'purchases', { $user_result->create_related( 'purchases', {
seller_id => $org_result->id, seller_id => $org_result->id,
value => 3, value => 300000,
proof_image => 'a', proof_image => 'a',
}); });
$user_result->create_related( 'purchases', { $user_result->create_related( 'purchases', {
seller_id => $org_result->id, seller_id => $org_result->id,
value => 1, value => 100000,
proof_image => 'a', proof_image => 'a',
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )), purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
}); });
@ -114,13 +114,13 @@ my $now = DateTime->today();
$user_result->create_related( 'purchases', { $user_result->create_related( 'purchases', {
seller_id => $org_result->id, seller_id => $org_result->id,
value => 5, value => 500000,
proof_image => 'a', proof_image => 'a',
}); });
$user_result->create_related( 'purchases', { $user_result->create_related( 'purchases', {
seller_id => $org_result->id, seller_id => $org_result->id,
value => 5, value => 500000,
proof_image => 'a', proof_image => 'a',
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )), purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
}); });
@ -131,13 +131,13 @@ my $now = DateTime->today();
$user_result->create_related( 'purchases', { $user_result->create_related( 'purchases', {
seller_id => $org_result->id, seller_id => $org_result->id,
value => 9, value => 900000,
proof_image => 'a', proof_image => 'a',
}); });
$user_result->create_related( 'purchases', { $user_result->create_related( 'purchases', {
seller_id => $org_result->id, seller_id => $org_result->id,
value => 3, value => 300000,
proof_image => 'a', proof_image => 'a',
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )), purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
}); });