Allow for day scale of transaction report

This commit is contained in:
Tom Bloor 2017-09-29 16:04:41 +01:00
parent bf74fcc44f
commit a739b02eed
3 changed files with 11 additions and 5 deletions

View file

@ -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 },
}
);

View file

@ -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,

View file

@ -31,7 +31,8 @@
Reports
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="<%= url_for '/admin/reports/transactions' %>">Transactions</a>
<a class="dropdown-item" href="<%= url_for '/admin/reports/transactions' %>">Transactions (Hourly)</a>
<a class="dropdown-item" href="<%= url_for('/admin/reports/transactions')->query(scale =>'days') %>">Transactions (Daily)</a>
</div>
</li>
<li class="nav-item">