diff --git a/lib/Pear/LocalLoop/Controller/Admin/Reports.pm b/lib/Pear/LocalLoop/Controller/Admin/Reports.pm index 658d4e5..a8be888 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Reports.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Reports.pm @@ -6,13 +6,18 @@ use Mojo::JSON qw/ encode_json /; sub transaction_data { my $c = shift; + my $quantised_column = 'quantised_hours'; + if ( $c->param('scale') eq 'days' ) { + $quantised_column = 'quantised_days'; + } + my $driver = $c->schema->storage->dbh->{Driver}->{Name}; my $transaction_rs = $c->schema->resultset('ViewQuantisedTransaction' . $driver)->search( {}, { columns => [ - 'quantised_hours', { + quantised => $quantised_column, count => \"COUNT(*)", sum_distance => $c->pg_or_sqlite( '', @@ -32,8 +37,8 @@ sub transaction_data { ), } ], - group_by => 'quantised_hours', - order_by => { '-asc' => 'quantised_hours' }, + group_by => $quantised_column, + order_by => { '-asc' => $quantised_column }, } ); diff --git a/templates/admin/reports/transaction_data.html.ep b/templates/admin/reports/transaction_data.html.ep index 04fee8d..69c914c 100644 --- a/templates/admin/reports/transaction_data.html.ep +++ b/templates/admin/reports/transaction_data.html.ep @@ -7,7 +7,7 @@ var raw_data = <%== $transaction_rs %>; var mapped_data = $.map(raw_data, function( val, i ) { return [ [ - new Date(val.quantised_hours), + new Date(val.quantised), val.count, val.average_value / 100000, val.sum_value / 100000, diff --git a/templates/layouts/admin.html.ep b/templates/layouts/admin.html.ep index eab4f4a..cacfeef 100644 --- a/templates/layouts/admin.html.ep +++ b/templates/layouts/admin.html.ep @@ -31,7 +31,8 @@ Reports