fixed api and quantised statement code

This commit is contained in:
Finn 2018-01-17 17:14:50 +00:00
parent d3f0ebb62f
commit 005388b27e
2 changed files with 9 additions and 18 deletions

View file

@ -3,15 +3,6 @@ use Mojo::Base 'Mojolicious::Controller';
use List::Util qw/ max sum /; use List::Util qw/ max sum /;
has error_messages => sub {
return {
type => {
required => { message => 'Type of Leaderboard Required', status => 400 },
in_resultset => { message => 'Unrecognised Leaderboard Type', status => 400 },
},
};
};
sub post_category_list { sub post_category_list {
my $c = shift; my $c = shift;
@ -47,7 +38,7 @@ sub post_category_list {
} }
); );
for ( $transaction_rs->all ) { for ( $month_transaction_rs->all ) {
my $quantised = $c->db_datetime_parser->parse_datetime($_->get_column('quantised')); my $quantised = $c->db_datetime_parser->parse_datetime($_->get_column('quantised'));
push @{ $data->{ days } }, ($c->format_iso_datetime( $quantised ) || 0); push @{ $data->{ days } }, ($c->format_iso_datetime( $quantised ) || 0);
push @{ $data->{ category } }, ($_->get_column('category_id') || 0); push @{ $data->{ category } }, ($_->get_column('category_id') || 0);

View file

@ -10,15 +10,15 @@ __PACKAGE__->table('view_quantised_transactions');
__PACKAGE__->result_source_instance->is_virtual(1); __PACKAGE__->result_source_instance->is_virtual(1);
__PACKAGE__->result_source_instance->view_definition( qq/ __PACKAGE__->result_source_instance->view_definition( qq/
SELECT "value", SELECT "transactions.value",
"distance", "transactions.distance",
"purchase_time", "transactions.purchase_time",
"buyer_id", "transactions.buyer_id",
"seller_id", "transactions.seller_id",
"transaction_category.category_id", "transaction_category.category_id",
DATETIME(STRFTIME('%Y-%m-%d %H:00:00',"purchase_time")) AS "quantised_hours", DATETIME(STRFTIME('%Y-%m-%d %H:00:00',"transactions.purchase_time")) AS "quantised_hours",
DATETIME(STRFTIME('%Y-%m-%d 00:00:00',"purchase_time")) AS "quantised_days", DATETIME(STRFTIME('%Y-%m-%d 00:00:00',"transactions.purchase_time")) AS "quantised_days",
DATETIME(STRFTIME('%Y-%m-%d 00:00:00',"purchase_time", 'weekday 1')) AS "quantised_weeks" DATETIME(STRFTIME('%Y-%m-%d 00:00:00',"transactions.purchase_time", 'weekday 1')) AS "quantised_weeks"
FROM "transactions" FROM "transactions"
LEFT JOIN "transaction_category" ON "transactions.id" = "transaction_category.transaction_id" LEFT JOIN "transaction_category" ON "transactions.id" = "transaction_category.transaction_id"
/); /);