aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Model/DB.pm4
-rw-r--r--perllib/FixMyStreet/DB.pm17
-rw-r--r--perllib/FixMyStreet/DB/Schema.pm25
-rw-r--r--perllib/FixMyStreet/Script/Alerts.pm4
-rwxr-xr-xperllib/FixMyStreet/Script/UpdateAllReports.pm2
-rw-r--r--perllib/FixMyStreet/Test.pm2
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm2
-rw-r--r--perllib/Open311/PopulateServiceList.pm2
8 files changed, 37 insertions, 21 deletions
diff --git a/perllib/FixMyStreet/App/Model/DB.pm b/perllib/FixMyStreet/App/Model/DB.pm
index ac1f98dc9..9d09186b8 100644
--- a/perllib/FixMyStreet/App/Model/DB.pm
+++ b/perllib/FixMyStreet/App/Model/DB.pm
@@ -7,8 +7,8 @@ use warnings;
use FixMyStreet;
__PACKAGE__->config(
- schema_class => 'FixMyStreet::DB',
- connect_info => sub { FixMyStreet::DB->storage->dbh },
+ schema_class => 'FixMyStreet::DB::Schema',
+ connect_info => sub { FixMyStreet::DB->schema->storage->dbh },
);
=head1 NAME
diff --git a/perllib/FixMyStreet/DB.pm b/perllib/FixMyStreet/DB.pm
index d920c809f..cee66b434 100644
--- a/perllib/FixMyStreet/DB.pm
+++ b/perllib/FixMyStreet/DB.pm
@@ -1,22 +1,13 @@
-use utf8;
package FixMyStreet::DB;
-# Created by DBIx::Class::Schema::Loader
-# DO NOT MODIFY THE FIRST PART OF THIS FILE
-
use strict;
use warnings;
+use FixMyStreet::DB::Schema;
-use base 'DBIx::Class::Schema';
-
-__PACKAGE__->load_namespaces;
-
-
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CjFpUvon7KggFM7OF7VK/w
+my $schema;
-use FixMyStreet;
+sub schema { $schema ||= FixMyStreet::DB::Schema->clone }
-__PACKAGE__->connection(FixMyStreet->dbic_connect_info);
+sub resultset { shift->schema->resultset(@_) }
1;
diff --git a/perllib/FixMyStreet/DB/Schema.pm b/perllib/FixMyStreet/DB/Schema.pm
new file mode 100644
index 000000000..7833ee68c
--- /dev/null
+++ b/perllib/FixMyStreet/DB/Schema.pm
@@ -0,0 +1,25 @@
+use utf8;
+package FixMyStreet::DB::Schema;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->load_namespaces(
+ result_namespace => "+FixMyStreet::DB::Result",
+ resultset_namespace => "+FixMyStreet::DB::ResultSet",
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07035 @ 2017-07-13 14:15:09
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:UpH30RXb6SbCqRv2FPmpkg
+
+use FixMyStreet;
+
+__PACKAGE__->connection(FixMyStreet->dbic_connect_info);
+
+1;
diff --git a/perllib/FixMyStreet/Script/Alerts.pm b/perllib/FixMyStreet/Script/Alerts.pm
index ef1bdb08b..aefe13318 100644
--- a/perllib/FixMyStreet/Script/Alerts.pm
+++ b/perllib/FixMyStreet/Script/Alerts.pm
@@ -62,7 +62,7 @@ sub send() {
$query =~ s/\?/alert.parameter/ if ($query =~ /\?/);
$query =~ s/\?/alert.parameter2/ if ($query =~ /\?/);
- $query = FixMyStreet::DB->storage->dbh->prepare($query);
+ $query = FixMyStreet::DB->schema->storage->dbh->prepare($query);
$query->execute();
my $last_alert_id;
my %data = ( template => $alert_type->template, data => [], schema => $schema );
@@ -225,7 +225,7 @@ sub send() {
and (select whenqueued from alert_sent where alert_sent.alert_id = ? and alert_sent.parameter::integer = problem.id) is null
and users.email <> ?
order by confirmed desc";
- $q = FixMyStreet::DB->storage->dbh->prepare($q);
+ $q = FixMyStreet::DB->schema->storage->dbh->prepare($q);
$q->execute($latitude, $longitude, $d, $alert->whensubscribed, $alert->id, $alert->user->email);
while (my $row = $q->fetchrow_hashref) {
$schema->resultset('AlertSent')->create( {
diff --git a/perllib/FixMyStreet/Script/UpdateAllReports.pm b/perllib/FixMyStreet/Script/UpdateAllReports.pm
index 51cb7b856..1bd069ee8 100755
--- a/perllib/FixMyStreet/Script/UpdateAllReports.pm
+++ b/perllib/FixMyStreet/Script/UpdateAllReports.pm
@@ -158,7 +158,7 @@ sub generate_dashboard {
);
$data{last_seven_days} = \%last_seven_days;
- my $dtf = FixMyStreet::DB->storage->datetime_parser;
+ my $dtf = FixMyStreet::DB->schema->storage->datetime_parser;
my $eight_ago = $dtf->format_datetime(DateTime->now->subtract(days => 8));
%problems_reported_by_period = stuff_by_day_or_year('day',
'Problem',
diff --git a/perllib/FixMyStreet/Test.pm b/perllib/FixMyStreet/Test.pm
index add67dfd9..6b6bc02bc 100644
--- a/perllib/FixMyStreet/Test.pm
+++ b/perllib/FixMyStreet/Test.pm
@@ -8,7 +8,7 @@ use utf8;
use Test::More;
use FixMyStreet::DB;
-my $db = FixMyStreet::DB->storage;
+my $db = FixMyStreet::DB->schema->storage;
sub import {
strict->import;
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index 30db24164..6ba53b7af 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -11,7 +11,7 @@ has start_date => ( is => 'ro', default => sub { undef } );
has end_date => ( is => 'ro', default => sub { undef } );
has suppress_alerts => ( is => 'rw', default => 0 );
has verbose => ( is => 'ro', default => 0 );
-has schema => ( is =>'ro', lazy => 1, default => sub { FixMyStreet::DB->connect } );
+has schema => ( is =>'ro', lazy => 1, default => sub { FixMyStreet::DB->schema->connect } );
Readonly::Scalar my $AREA_ID_BROMLEY => 2482;
Readonly::Scalar my $AREA_ID_OXFORDSHIRE => 2237;
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm
index 540425bf1..764207626 100644
--- a/perllib/Open311/PopulateServiceList.pm
+++ b/perllib/Open311/PopulateServiceList.pm
@@ -6,7 +6,7 @@ use Open311;
has bodies => ( is => 'ro' );
has found_contacts => ( is => 'rw', default => sub { [] } );
has verbose => ( is => 'ro', default => 0 );
-has schema => ( is => 'ro', lazy => 1, default => sub { FixMyStreet::DB->connect } );
+has schema => ( is => 'ro', lazy => 1, default => sub { FixMyStreet::DB->schema->connect } );
has _current_body => ( is => 'rw' );
has _current_open311 => ( is => 'rw' );