diff --git a/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm b/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm index bb807ba..bc78d91 100644 --- a/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm +++ b/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm @@ -56,7 +56,7 @@ sub graph_customers_last_30_days { sub _customers_last_duration { my ( $c, $duration ) = @_; - my $org = $c->stash->{api_user}->organisation; + my $org = $c->stash->{api_user}->entity; my $data = { day => [], count => [] }; diff --git a/t/api/v1/organisation/graphs.t b/t/api/v1/organisation/graphs.t index d6885f3..c5ee6f9 100644 --- a/t/api/v1/organisation/graphs.t +++ b/t/api/v1/organisation/graphs.t @@ -77,9 +77,11 @@ sub create_random_transaction { my $buyer = shift; my $time = shift; + my $buyer_result = $schema->resultset('User')->find({ email => $buyer })->entity; + my $seller_result = $schema->resultset('Organisation')->find({ name => 'Test Org' })->entity; $schema->resultset('Transaction')->create({ - buyer => { email => $buyer }, - seller => { name => 'Test Org' }, + buyer => $buyer_result, + seller => $seller_result, value => ( int( rand( 10000 ) ) / 100 ), proof_image => 'a', purchase_time => $time,