From e13a12817963b617ea4566635a298d79471cf648 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Fri, 8 Sep 2017 12:00:23 +0100 Subject: [PATCH 1/2] Add zero to sums to force number on output --- lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm b/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm index 5b4eab5..24e4263 100644 --- a/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm +++ b/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm @@ -102,7 +102,7 @@ sub _sales_last_duration { my $transactions = $entity->sales ->search_between( $start, $next_end ) ->get_column('value') - ->sum || 0; + ->sum + 0; push @{ $data->{ labels } }, $start->day_name; push @{ $data->{ data } }, $transactions; $start->add( days => 1 ); @@ -134,7 +134,7 @@ sub _purchases_last_duration { my $transactions = $entity->purchases ->search_between( $start, $next_end ) ->get_column('value') - ->sum || 0; + ->sum + 0; push @{ $data->{ labels } }, $start->day_name; push @{ $data->{ data } }, $transactions; $start->add( days => 1 ); From 83094f380db9a3ab4589796ea577e46b3080270d Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Fri, 8 Sep 2017 12:03:48 +0100 Subject: [PATCH 2/2] Continue defaulting to 0 as well --- lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm b/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm index 24e4263..b414152 100644 --- a/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm +++ b/lib/Pear/LocalLoop/Controller/Api/V1/Organisation/Graphs.pm @@ -102,7 +102,7 @@ sub _sales_last_duration { my $transactions = $entity->sales ->search_between( $start, $next_end ) ->get_column('value') - ->sum + 0; + ->sum || 0 + 0; push @{ $data->{ labels } }, $start->day_name; push @{ $data->{ data } }, $transactions; $start->add( days => 1 ); @@ -134,7 +134,7 @@ sub _purchases_last_duration { my $transactions = $entity->purchases ->search_between( $start, $next_end ) ->get_column('value') - ->sum + 0; + ->sum || 0 + 0; push @{ $data->{ labels } }, $start->day_name; push @{ $data->{ data } }, $transactions; $start->add( days => 1 );