Allow for day scale of transaction report
This commit is contained in:
parent
bf74fcc44f
commit
a739b02eed
3 changed files with 11 additions and 5 deletions
|
@ -6,13 +6,18 @@ use Mojo::JSON qw/ encode_json /;
|
||||||
sub transaction_data {
|
sub transaction_data {
|
||||||
my $c = shift;
|
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 $driver = $c->schema->storage->dbh->{Driver}->{Name};
|
||||||
my $transaction_rs = $c->schema->resultset('ViewQuantisedTransaction' . $driver)->search(
|
my $transaction_rs = $c->schema->resultset('ViewQuantisedTransaction' . $driver)->search(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
columns => [
|
columns => [
|
||||||
'quantised_hours',
|
|
||||||
{
|
{
|
||||||
|
quantised => $quantised_column,
|
||||||
count => \"COUNT(*)",
|
count => \"COUNT(*)",
|
||||||
sum_distance => $c->pg_or_sqlite(
|
sum_distance => $c->pg_or_sqlite(
|
||||||
'',
|
'',
|
||||||
|
@ -32,8 +37,8 @@ sub transaction_data {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
group_by => 'quantised_hours',
|
group_by => $quantised_column,
|
||||||
order_by => { '-asc' => 'quantised_hours' },
|
order_by => { '-asc' => $quantised_column },
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ var raw_data = <%== $transaction_rs %>;
|
||||||
var mapped_data = $.map(raw_data, function( val, i ) {
|
var mapped_data = $.map(raw_data, function( val, i ) {
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
new Date(val.quantised_hours),
|
new Date(val.quantised),
|
||||||
val.count,
|
val.count,
|
||||||
val.average_value / 100000,
|
val.average_value / 100000,
|
||||||
val.sum_value / 100000,
|
val.sum_value / 100000,
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
Reports
|
Reports
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu">
|
<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>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
|
|
Reference in a new issue