diff --git a/lib/Pear/LocalLoop/Controller/Api/Stats.pm b/lib/Pear/LocalLoop/Controller/Api/Stats.pm index bf15384..3ee2617 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Stats.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Stats.pm @@ -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, diff --git a/t/api/stats_leaderboards.t b/t/api/stats_leaderboards.t index 11003c2..84eb331 100644 --- a/t/api/stats_leaderboards.t +++ b/t/api/stats_leaderboards.t @@ -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',