fixed api and quantised statement code
This commit is contained in:
parent
b383284519
commit
6fe4cd9a31
2 changed files with 9 additions and 18 deletions
|
@ -3,15 +3,6 @@ use Mojo::Base 'Mojolicious::Controller';
|
|||
|
||||
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 {
|
||||
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'));
|
||||
push @{ $data->{ days } }, ($c->format_iso_datetime( $quantised ) || 0);
|
||||
push @{ $data->{ category } }, ($_->get_column('category_id') || 0);
|
||||
|
|
|
@ -10,15 +10,15 @@ __PACKAGE__->table('view_quantised_transactions');
|
|||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
|
||||
__PACKAGE__->result_source_instance->view_definition( qq/
|
||||
SELECT "value",
|
||||
"distance",
|
||||
"purchase_time",
|
||||
"buyer_id",
|
||||
"seller_id",
|
||||
SELECT "transactions.value",
|
||||
"transactions.distance",
|
||||
"transactions.purchase_time",
|
||||
"transactions.buyer_id",
|
||||
"transactions.seller_id",
|
||||
"transaction_category.category_id",
|
||||
DATETIME(STRFTIME('%Y-%m-%d %H:00:00',"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',"purchase_time", 'weekday 1')) AS "quantised_weeks"
|
||||
DATETIME(STRFTIME('%Y-%m-%d %H:00:00',"transactions.purchase_time")) AS "quantised_hours",
|
||||
DATETIME(STRFTIME('%Y-%m-%d 00:00:00',"transactions.purchase_time")) AS "quantised_days",
|
||||
DATETIME(STRFTIME('%Y-%m-%d 00:00:00',"transactions.purchase_time", 'weekday 1')) AS "quantised_weeks"
|
||||
FROM "transactions"
|
||||
LEFT JOIN "transaction_category" ON "transactions.id" = "transaction_category.transaction_id"
|
||||
/);
|
||||
|
|
Reference in a new issue