aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/Problem.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-09-25 22:35:39 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-12-02 17:41:35 +0000
commit55412b79394ff1b1cabe368aed67fa8f68680ecc (patch)
tree33657093517818b8ba60f156484ec540f9c4af17 /perllib/FixMyStreet/DB/Result/Problem.pm
parent0c2a792b154e1b28528db887bbde80b19268b9fe (diff)
Reduce use of FixMyStreet::App.
Command line scripts don't need a full blown app, just database.
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm29
1 files changed, 13 insertions, 16 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 0cab853de..e340acf1e 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -462,7 +462,7 @@ sub bodies($) {
my $self = shift;
return {} unless $self->bodies_str;
my $bodies = $self->bodies_str_ids;
- my @bodies = FixMyStreet::App->model('DB::Body')->search({ id => $bodies })->all;
+ my @bodies = $self->result_source->schema->resultset('Body')->search({ id => $bodies })->all;
return { map { $_->id => $_ } @bodies };
}
@@ -648,7 +648,7 @@ order of title.
sub response_templates {
my $problem = shift;
- return FixMyStreet::App->model('DB::ResponseTemplate')->search(
+ return $problem->result_source->schema->resultset('ResponseTemplate')->search(
{
body_id => $problem->bodies_str_ids
},
@@ -754,20 +754,17 @@ sub update_from_open311_service_request {
$status_notes = $request->{status_notes};
}
- my $update = FixMyStreet::App->model('DB::Comment')->new(
- {
- problem_id => $self->id,
- state => 'confirmed',
- created => $updated || \'current_timestamp',
- confirmed => \'current_timestamp',
- text => $status_notes,
- mark_open => 0,
- mark_fixed => 0,
- user => $system_user,
- anonymous => 0,
- name => $body->name,
- }
- );
+ my $update = $self->new_related(comments => {
+ state => 'confirmed',
+ created => $updated || \'current_timestamp',
+ confirmed => \'current_timestamp',
+ text => $status_notes,
+ mark_open => 0,
+ mark_fixed => 0,
+ user => $system_user,
+ anonymous => 0,
+ name => $body->name,
+ });
my $w3c = DateTime::Format::W3CDTF->new;
my $req_time = $w3c->parse_datetime( $request->{updated_datetime} );