2017-09-29 13:45:44 +00:00
|
|
|
package Pear::LocalLoop::Schema::Result::ViewQuantisedTransactionSQLite;
|
|
|
|
|
|
|
|
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/
|
2017-09-29 13:45:44 +00:00
|
|
|
SELECT "value",
|
|
|
|
"distance",
|
|
|
|
"purchase_time",
|
2017-12-15 15:30:47 +00:00
|
|
|
"buyer_id",
|
|
|
|
"seller_id",
|
2019-07-12 12:39:37 +00:00
|
|
|
"sector",
|
2017-09-29 13:45:44 +00:00
|
|
|
DATETIME(STRFTIME('%Y-%m-%d %H:00:00',"purchase_time")) AS "quantised_hours",
|
2017-12-14 20:30:44 +00:00
|
|
|
DATETIME(STRFTIME('%Y-%m-%d 00:00:00',"purchase_time")) AS "quantised_days",
|
2019-07-12 12:39:37 +00:00
|
|
|
DATETIME(STRFTIME('%Y-%m-%d 00:00:00',"purchase_time",'weekday 0','-6 days')) AS "quantised_weeks",
|
|
|
|
DATETIME(STRFTIME('%Y-%m-00 00:00:00',"purchase_time")) AS "quantised_months"
|
2017-09-29 13:45:44 +00:00
|
|
|
FROM "transactions"
|
2021-03-20 12:09:50 +00:00
|
|
|
/
|
|
|
|
);
|
2017-09-29 13:45:44 +00:00
|
|
|
|
2019-09-09 17:03:08 +00:00
|
|
|
__PACKAGE__->belongs_to(
|
2021-03-20 12:09:50 +00:00
|
|
|
"buyer",
|
|
|
|
"Pear::LocalLoop::Schema::Result::Entity",
|
|
|
|
{ id => "buyer_id" },
|
|
|
|
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
|
2019-09-09 17:03:08 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
__PACKAGE__->belongs_to(
|
2021-03-20 12:09:50 +00:00
|
|
|
"seller",
|
|
|
|
"Pear::LocalLoop::Schema::Result::Entity",
|
|
|
|
{ id => "seller_id" },
|
|
|
|
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
|
2019-09-09 17:03:08 +00:00
|
|
|
);
|
|
|
|
|
2017-09-29 13:45:44 +00:00
|
|
|
1;
|