2017-08-25 16:36:43 +01:00
#! /usr/bin/env perl
use strict ;
use warnings ;
use DBIx::Class::Fixtures ;
use FindBin qw/ $Bin / ;
use lib "$Bin/../../../../lib" ;
use Pear::LocalLoop::Schema ;
use DateTime ;
my $ fixtures = DBIx::Class::Fixtures - > new ( {
config_dir = > "$Bin" ,
} ) ;
my $ schema = Pear::LocalLoop::Schema - > connect ( 'dbi:SQLite::memory:' ) ;
$ schema - > deploy ;
$ schema - > resultset ( 'Leaderboard' ) - > populate ( [
[ qw/ name type / ] ,
[ 'Daily Total' , 'daily_total' ] ,
[ 'Daily Count' , 'daily_count' ] ,
[ 'Weekly Total' , 'weekly_total' ] ,
[ 'Weekly Count' , 'weekly_count' ] ,
[ 'Monthly Total' , 'monthly_total' ] ,
[ 'Monthly Count' , 'monthly_count' ] ,
[ 'All Time Total' , 'all_time_total' ] ,
[ 'All Time Count' , 'all_time_count' ] ,
] ) ;
2017-08-31 13:18:04 +01:00
my $ entity1 = {
2017-08-25 16:36:43 +01:00
customer = > {
full_name = > 'Test User1' ,
display_name = > 'Test User1' ,
postcode = > 'LA1 1AA' ,
year_of_birth = > 2006 ,
} ,
2017-08-31 13:18:04 +01:00
user = > {
email = > 'test1@example.com' ,
password = > 'abc123' ,
} ,
type = > "customer" ,
2017-08-25 16:36:43 +01:00
} ;
2017-08-31 13:18:04 +01:00
my $ entity2 = {
2017-08-25 16:36:43 +01:00
customer = > {
2017-08-31 13:18:04 +01:00
full_name = > 'Test User2' ,
display_name = > 'Test User2' ,
postcode = > 'LA1 1AA' ,
2017-08-25 16:36:43 +01:00
year_of_birth = > 2006 ,
} ,
2017-08-31 13:18:04 +01:00
user = > {
email = > 'test2@example.com' ,
password = > 'abc123' ,
} ,
type = > "customer" ,
2017-08-25 16:36:43 +01:00
} ;
2017-08-31 13:18:04 +01:00
my $ entity3 = {
2017-08-25 16:36:43 +01:00
customer = > {
2017-08-31 13:18:04 +01:00
full_name = > 'Test User3' ,
display_name = > 'Test User3' ,
postcode = > 'LA1 1AA' ,
2017-08-25 16:36:43 +01:00
year_of_birth = > 2006 ,
} ,
2017-08-31 13:18:04 +01:00
user = > {
email = > 'test3@example.com' ,
password = > 'abc123' ,
} ,
type = > "customer" ,
2017-08-25 16:36:43 +01:00
} ;
2017-08-31 13:18:04 +01:00
my $ entity4 = {
2017-08-25 16:36:43 +01:00
customer = > {
2017-08-31 13:18:04 +01:00
full_name = > 'Test User4' ,
display_name = > 'Test User4' ,
postcode = > 'LA1 1AA' ,
2017-08-25 16:36:43 +01:00
year_of_birth = > 2006 ,
} ,
2017-08-31 13:18:04 +01:00
user = > {
email = > 'test4@example.com' ,
password = > 'abc123' ,
} ,
type = > "customer" ,
2017-08-25 16:36:43 +01:00
} ;
2017-08-31 13:18:04 +01:00
my $ entity5 = {
2017-08-25 16:36:43 +01:00
organisation = > {
name = > 'Test Org' ,
street_name = > 'Test Street' ,
town = > 'Lancaster' ,
postcode = > 'LA1 1AA' ,
2017-12-15 17:52:02 +00:00
sector = > 'A' ,
2017-08-25 16:36:43 +01:00
} ,
2017-08-31 13:18:04 +01:00
user = > {
email = > 'org@example.com' ,
password = > 'abc123' ,
} ,
2017-08-31 16:35:51 +01:00
type = > "organisation" ,
2017-08-31 13:18:04 +01:00
} ;
my $ entity6 = {
customer = > {
full_name = > 'Test Admin' ,
display_name = > 'Test Admin' ,
postcode = > 'LA1 1AA' ,
year_of_birth = > 2006 ,
} ,
user = > {
email = > 'admin@example.com' ,
password = > 'abc123' ,
is_admin = > \ "1" ,
} ,
type = > "customer" ,
2017-08-25 16:36:43 +01:00
} ;
2017-08-31 13:18:04 +01:00
$ schema - > resultset ( 'Entity' ) - > create ( $ _ )
for ( $ entity1 , $ entity2 , $ entity3 , $ entity4 , $ entity5 , $ entity6 ) ;
2017-08-25 16:36:43 +01:00
my $ data_set = 'users' ;
$ fixtures - > dump ( {
all = > 1 ,
schema = > $ schema ,
directory = > "$Bin/../data/" . $ data_set ,
} ) ;