aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB')
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm36
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm6
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm10
3 files changed, 26 insertions, 26 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index ae5815143..2d65c8789 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -24,7 +24,7 @@ __PACKAGE__->add_columns(
{ data_type => "double precision", is_nullable => 0 },
"longitude",
{ data_type => "double precision", is_nullable => 0 },
- "council",
+ "bodies_str",
{ data_type => "text", is_nullable => 1 },
"areas",
{ data_type => "text", is_nullable => 0 },
@@ -122,8 +122,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-10 15:33:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YZzkUjX7Dsxcsm4bXZjIYg
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-13 15:13:48
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:H2P3Og37G569nQdQA1IWaA
# Add fake relationship to stored procedure table
__PACKAGE__->has_one(
@@ -333,9 +333,9 @@ sub check_for_errors {
$errors{detail} = _('Please enter some details')
unless $self->detail =~ m/\S/;
- $errors{council} = _('No council selected')
- unless $self->council
- && $self->council =~ m/^(?:-1|[\d,]+(?:\|[\d,]+)?)$/;
+ $errors{bodies} = _('No council selected')
+ unless $self->bodies_str
+ && $self->bodies_str =~ m/^(?:-1|[\d,]+(?:\|[\d,]+)?)$/;
if ( !$self->name || $self->name !~ m/\S/ ) {
$errors{name} = _('Please enter your name');
@@ -388,18 +388,19 @@ sub confirm {
return 1;
}
-=head2 councils
+=head2 bodies
-Returns an arrayref of councils to which a report was sent.
+Returns an arrayref of bodies to which a report was sent.
=cut
-sub councils {
+sub bodies($) {
my $self = shift;
- return [] unless $self->council;
- (my $council = $self->council) =~ s/\|.*$//;
- my @council = split( /,/, $council );
- return \@council;
+ return [] unless $self->bodies_str;
+ (my $bodies = $self->bodies_str) =~ s/\|.*$//;
+ my @bodies = split( /,/, $bodies );
+ @bodies = FixMyStreet::App->model('DB::Body')->search({ id => \@bodies })->all;
+ return { map { $_->id => $_ } @bodies };
}
=head2 url
@@ -555,19 +556,18 @@ sub body {
if ($problem->external_body) {
$body = $problem->external_body;
} else {
- my $councils = $problem->councils;
- my $areas_info = mySociety::MaPit::call('areas', $councils);
+ my $bodies = $problem->bodies;
$body = join( _(' and '),
map {
- my $name = $areas_info->{$_}->{name};
+ my $name = $_->name;
if (mySociety::Config::get('AREA_LINKS_FROM_PROBLEMS')) {
'<a href="'
- . $c->uri_for( '/reports/' . $c->cobrand->short_name( $areas_info->{$_} ) )
+ # XXX . $c->uri_for( '/reports/' . $c->cobrand->short_name( $areas_info->{$_} ) )
. '">' . $name . '</a>';
} else {
$name;
}
- } @$councils
+ } values %$bodies
);
}
return $body;
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index 468df2654..be1f6578b 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -89,7 +89,7 @@ sub email_alerts ($) {
}
my $url = $cobrand->base_url( $row->{alert_cobrand_data} );
- if ( $hashref_restriction && $hashref_restriction->{council} && $row->{council} ne $hashref_restriction->{council} ) {
+ if ( $hashref_restriction && $hashref_restriction->{bodies_str} && $row->{bodies_str} ne $hashref_restriction->{bodies_str} ) {
$url = mySociety::Config::get('BASE_URL');
}
# this is currently only for new_updates
@@ -166,7 +166,7 @@ sub email_alerts ($) {
};
my $states = "'" . join( "', '", FixMyStreet::DB::Result::Problem::visible_states() ) . "'";
my %data = ( template => $template, data => '', alert_id => $alert->id, alert_email => $alert->user->email, lang => $alert->lang, cobrand => $alert->cobrand, cobrand_data => $alert->cobrand_data );
- my $q = "select problem.id, problem.council, problem.postcode, problem.geocode, problem.title from problem_find_nearby(?, ?, ?) as nearby, problem, users
+ my $q = "select problem.id, problem.bodies_str, problem.postcode, problem.geocode, problem.title from problem_find_nearby(?, ?, ?) as nearby, problem, users
where nearby.problem_id = problem.id
and problem.user_id = users.id
and problem.state in ($states)
@@ -183,7 +183,7 @@ sub email_alerts ($) {
parameter => $row->{id},
} );
my $url = $cobrand->base_url( $alert->cobrand_data );
- if ( $hashref_restriction && $hashref_restriction->{council} && $row->{council} ne $hashref_restriction->{council} ) {
+ if ( $hashref_restriction && $hashref_restriction->{bodies_str} && $row->{bodies_str} ne $hashref_restriction->{bodies_str} ) {
$url = mySociety::Config::get('BASE_URL');
}
$data{data} .= $url . "/report/" . $row->{id} . " - $row->{title}\n\n";
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 4d8004024..16eca144d 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -228,7 +228,7 @@ sub send_reports {
my $unsent = FixMyStreet::App->model("DB::Problem")->search( {
state => [ 'confirmed', 'fixed' ],
whensent => undef,
- bodies => { '!=', undef },
+ bodies_str => { '!=', undef },
} );
my (%notgot, %note);
@@ -292,7 +292,7 @@ sub send_reports {
my ( $sender_count );
if ($site eq 'emptyhomes') {
- my $body = $row->bodies;
+ my $body = $row->bodies_str;
$body = FixMyStreet::App->model("DB::Body")->find($body);
my $sender = "FixMyStreet::SendReport::EmptyHomes";
$reporters{ $sender } = $sender->new() unless $reporters{$sender};
@@ -302,7 +302,7 @@ sub send_reports {
# XXX Needs locks!
# XXX Only copes with at most one missing body
- my ($bodies, $missing) = $row->bodies =~ /^([\d,]+)(?:\|(\d+))?/;
+ my ($bodies, $missing) = $row->bodies_str =~ /^([\d,]+)(?:\|(\d+))?/;
my @bodies = split(/,/, $bodies);
$bodies = FixMyStreet::App->model("DB::Body")->search({ id => \@bodies });
$missing = FixMyStreet::App->model("DB::Body")->find($missing);
@@ -362,7 +362,7 @@ sub send_reports {
if (mySociety::Config::get('STAGING_SITE')) {
# on a staging server send emails to ourselves rather than the bodies
my @testing_bodies = split( '\|', mySociety::Config::get('TESTING_COUNCILS') );
- unless ( grep { $row->bodies eq $_ } @testing_bodies ) {
+ unless ( grep { $row->bodies_str eq $_ } @testing_bodies ) {
%reporters = map { $_ => $reporters{$_} } grep { /FixMyStreet::SendReport::(Email|NI)/ } keys %reporters;
unless (%reporters) {
%reporters = ( 'FixMyStreet::SendReport::Email' => FixMyStreet::SendReport::Email->new() );
@@ -424,7 +424,7 @@ sub send_reports {
my $unsent = FixMyStreet::App->model("DB::Problem")->search( {
state => [ 'confirmed', 'fixed' ],
whensent => undef,
- bodies => { '!=', undef },
+ bodies_str => { '!=', undef },
send_fail_count => { '>', 0 }
} );
while (my $row = $unsent->next) {