Fixed stats endpoint for leaderboards on entity upgrade
This commit is contained in:
parent
96c8fa16c8
commit
e91863a3d7
2 changed files with 15 additions and 15 deletions
|
@ -84,14 +84,14 @@ sub post_leaderboards {
|
||||||
/,
|
/,
|
||||||
{ display_name => 'customer.display_name' },
|
{ display_name => 'customer.display_name' },
|
||||||
],
|
],
|
||||||
join => { user => 'customer' },
|
join => { entity => 'customer' },
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
$today_values->result_class( 'DBIx::Class::ResultClass::HashRefInflator' );
|
$today_values->result_class( 'DBIx::Class::ResultClass::HashRefInflator' );
|
||||||
|
|
||||||
my @leaderboard_array = $today_values->all;
|
my @leaderboard_array = $today_values->all;
|
||||||
|
|
||||||
my $current_user_position = $today_values->find({ user_id => $c->stash->{api_user}->id });
|
my $current_user_position = $today_values->find({ entity_id => $c->stash->{api_user}->entity->id });
|
||||||
|
|
||||||
return $c->render( json => {
|
return $c->render( json => {
|
||||||
success => Mojo::JSON->true,
|
success => Mojo::JSON->true,
|
||||||
|
|
|
@ -69,22 +69,22 @@ $framework->register_customer($_)
|
||||||
|
|
||||||
$framework->register_organisation($org);
|
$framework->register_organisation($org);
|
||||||
|
|
||||||
my $org_result = $schema->resultset('Organisation')->find({ name => $org->{name} });
|
my $org_result = $schema->resultset('Organisation')->find({ name => $org->{name} })->entity;
|
||||||
|
|
||||||
my $tweak = 0;
|
my $tweak = 0;
|
||||||
|
|
||||||
my $now = DateTime->today();
|
my $now = DateTime->today();
|
||||||
|
|
||||||
{
|
{
|
||||||
my $user_result = $schema->resultset('User')->find({ email => $user1->{email} });
|
my $user_result = $schema->resultset('User')->find({ email => $user1->{email} })->entity;
|
||||||
|
|
||||||
$user_result->create_related( 'transactions', {
|
$user_result->create_related( 'purchases', {
|
||||||
seller_id => $org_result->id,
|
seller_id => $org_result->id,
|
||||||
value => 1,
|
value => 1,
|
||||||
proof_image => 'a',
|
proof_image => 'a',
|
||||||
});
|
});
|
||||||
|
|
||||||
$user_result->create_related( 'transactions', {
|
$user_result->create_related( 'purchases', {
|
||||||
seller_id => $org_result->id,
|
seller_id => $org_result->id,
|
||||||
value => 9,
|
value => 9,
|
||||||
proof_image => 'a',
|
proof_image => 'a',
|
||||||
|
@ -93,15 +93,15 @@ my $now = DateTime->today();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
my $user_result = $schema->resultset('User')->find({ email => $user2->{email} });
|
my $user_result = $schema->resultset('User')->find({ email => $user2->{email} })->entity;
|
||||||
|
|
||||||
$user_result->create_related( 'transactions', {
|
$user_result->create_related( 'purchases', {
|
||||||
seller_id => $org_result->id,
|
seller_id => $org_result->id,
|
||||||
value => 3,
|
value => 3,
|
||||||
proof_image => 'a',
|
proof_image => 'a',
|
||||||
});
|
});
|
||||||
|
|
||||||
$user_result->create_related( 'transactions', {
|
$user_result->create_related( 'purchases', {
|
||||||
seller_id => $org_result->id,
|
seller_id => $org_result->id,
|
||||||
value => 1,
|
value => 1,
|
||||||
proof_image => 'a',
|
proof_image => 'a',
|
||||||
|
@ -110,15 +110,15 @@ my $now = DateTime->today();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
my $user_result = $schema->resultset('User')->find({ email => $user3->{email} });
|
my $user_result = $schema->resultset('User')->find({ email => $user3->{email} })->entity;
|
||||||
|
|
||||||
$user_result->create_related( 'transactions', {
|
$user_result->create_related( 'purchases', {
|
||||||
seller_id => $org_result->id,
|
seller_id => $org_result->id,
|
||||||
value => 5,
|
value => 5,
|
||||||
proof_image => 'a',
|
proof_image => 'a',
|
||||||
});
|
});
|
||||||
|
|
||||||
$user_result->create_related( 'transactions', {
|
$user_result->create_related( 'purchases', {
|
||||||
seller_id => $org_result->id,
|
seller_id => $org_result->id,
|
||||||
value => 5,
|
value => 5,
|
||||||
proof_image => 'a',
|
proof_image => 'a',
|
||||||
|
@ -127,15 +127,15 @@ my $now = DateTime->today();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
my $user_result = $schema->resultset('User')->find({ email => $user4->{email} });
|
my $user_result = $schema->resultset('User')->find({ email => $user4->{email} })->entity;
|
||||||
|
|
||||||
$user_result->create_related( 'transactions', {
|
$user_result->create_related( 'purchases', {
|
||||||
seller_id => $org_result->id,
|
seller_id => $org_result->id,
|
||||||
value => 9,
|
value => 9,
|
||||||
proof_image => 'a',
|
proof_image => 'a',
|
||||||
});
|
});
|
||||||
|
|
||||||
$user_result->create_related( 'transactions', {
|
$user_result->create_related( 'purchases', {
|
||||||
seller_id => $org_result->id,
|
seller_id => $org_result->id,
|
||||||
value => 3,
|
value => 3,
|
||||||
proof_image => 'a',
|
proof_image => 'a',
|
||||||
|
|
Reference in a new issue