Fixed stats endpoint for leaderboards on entity upgrade

This commit is contained in:
Tom Bloor 2017-08-31 18:31:42 +01:00
parent 96c8fa16c8
commit e91863a3d7
2 changed files with 15 additions and 15 deletions

View file

@ -84,14 +84,14 @@ sub post_leaderboards {
/,
{ display_name => 'customer.display_name' },
],
join => { user => 'customer' },
join => { entity => 'customer' },
},
);
$today_values->result_class( 'DBIx::Class::ResultClass::HashRefInflator' );
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 => {
success => Mojo::JSON->true,

View file

@ -69,22 +69,22 @@ $framework->register_customer($_)
$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 $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,
value => 1,
proof_image => 'a',
});
$user_result->create_related( 'transactions', {
$user_result->create_related( 'purchases', {
seller_id => $org_result->id,
value => 9,
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,
value => 3,
proof_image => 'a',
});
$user_result->create_related( 'transactions', {
$user_result->create_related( 'purchases', {
seller_id => $org_result->id,
value => 1,
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,
value => 5,
proof_image => 'a',
});
$user_result->create_related( 'transactions', {
$user_result->create_related( 'purchases', {
seller_id => $org_result->id,
value => 5,
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,
value => 9,
proof_image => 'a',
});
$user_result->create_related( 'transactions', {
$user_result->create_related( 'purchases', {
seller_id => $org_result->id,
value => 3,
proof_image => 'a',