From 9f9a79c69d5ca90bfd5f8e67e90934ee55a4065c Mon Sep 17 00:00:00 2001 From: Finn Date: Mon, 18 Dec 2017 15:36:24 +0000 Subject: [PATCH] reverted fix and did different fix to order_by --- lib/Pear/LocalLoop/Controller/Admin/Reports.pm | 5 +---- lib/Pear/LocalLoop/Controller/Api/Stats.pm | 12 +++--------- .../LocalLoop/Controller/Api/V1/Customer/Graphs.pm | 5 +---- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/lib/Pear/LocalLoop/Controller/Admin/Reports.pm b/lib/Pear/LocalLoop/Controller/Admin/Reports.pm index 494cc10..aff6bc9 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Reports.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Reports.pm @@ -18,10 +18,7 @@ sub transaction_data { columns => [ { quantised => $quantised_column, - count => $c->pg_or_sqlite( - 'count', - "COUNT(*)", - ), + count => \"COUNT(*)", sum_distance => $c->pg_or_sqlite( 'SUM("me"."distance")', 'SUM("me"."distance")', diff --git a/lib/Pear/LocalLoop/Controller/Api/Stats.pm b/lib/Pear/LocalLoop/Controller/Api/Stats.pm index 5d5f32c..ccbb435 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Stats.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Stats.pm @@ -86,10 +86,7 @@ sub post_customer { columns => [ { quantised => 'quantised_weeks', - count => $c->pg_or_sqlite( - 'count', - "COUNT(*)", - ), + count => \"COUNT(*)", } ], group_by => 'quantised_weeks', @@ -106,13 +103,10 @@ sub post_customer { join => { 'seller' => 'organisation' }, columns => { sector => "organisation.sector", - count => $c->pg_or_sqlite( - 'count', - "COUNT(*)", - ), + count => \"COUNT(*)", }, group_by => "organisation.sector", - order_by => { '-desc' => "COUNT(*)" }, + order_by => { '-desc' => $c->pg_or_sqlite('count',"COUNT(*)",)}, } ); diff --git a/lib/Pear/LocalLoop/Controller/Api/V1/Customer/Graphs.pm b/lib/Pear/LocalLoop/Controller/Api/V1/Customer/Graphs.pm index b461220..f48e52b 100644 --- a/lib/Pear/LocalLoop/Controller/Api/V1/Customer/Graphs.pm +++ b/lib/Pear/LocalLoop/Controller/Api/V1/Customer/Graphs.pm @@ -112,10 +112,7 @@ sub _purchases_avg_spend_duration { columns => [ { quantised => 'quantised_days', - count => $c->pg_or_sqlite( - 'count', - "COUNT(*)", - ), + count => \"COUNT(*)", sum_value => $c->pg_or_sqlite( 'SUM("me"."value")', 'SUM("me"."value")',