This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
Foodloop-Server/lib/Pear/LocalLoop/Schema/Result/ViewQuantisedTransactionCategorySQLite.pm

30 lines
1 KiB
Perl
Raw Normal View History

package Pear::LocalLoop::Schema::Result::ViewQuantisedTransactionCategorySQLite;
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
__PACKAGE__->table('view_quantised_transactions');
__PACKAGE__->result_source_instance->is_virtual(1);
2021-03-20 12:09:50 +00:00
__PACKAGE__->result_source_instance->view_definition(
qq/
2018-01-22 16:26:45 +00:00
SELECT "transactions"."value",
"transactions"."distance",
"transactions"."purchase_time",
"transactions"."buyer_id",
"transactions"."seller_id",
"transactions"."essential",
2018-01-22 16:26:45 +00:00
"transaction_category"."category_id",
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",
2018-03-21 15:52:00 +00:00
DATETIME(STRFTIME('%Y-%m-%d 00:00:00',"transactions"."purchase_time", 'weekday 0','-6 days')) AS "quantised_weeks"
FROM "transactions"
2018-01-22 16:26:45 +00:00
LEFT JOIN "transaction_category" ON "transactions"."id" = "transaction_category"."transaction_id"
2021-03-20 12:09:50 +00:00
/
);
1;