diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2015-08-19 15:44:02 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2015-08-19 15:46:16 +0100 |
commit | efa106c52e2668715d17b860a8afa71501691185 (patch) | |
tree | 510aba995e818f5500b980b2a904a3e790b0b1c8 /perllib/FixMyStreet/DB | |
parent | ad81d87a957b5590fbcba3f2325526a9cddcbb7f (diff) |
Move "missing" handling to separate column.
Diffstat (limited to 'perllib/FixMyStreet/DB')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 11 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Problem.pm | 19 |
2 files changed, 18 insertions, 12 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index b3e907d92..88794ee52 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -104,6 +104,8 @@ __PACKAGE__->add_columns( { data_type => "integer", default_value => 0, is_nullable => 1 }, "subcategory", { data_type => "text", is_nullable => 1 }, + "bodies_missing", + { data_type => "text", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->has_many( @@ -132,8 +134,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07035 @ 2014-07-31 15:57:02 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EvD4sS1mdJJyI1muZ4TrCw +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2015-08-13 16:33:38 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Go+T9oFRfwQ1Ag89qPpF/g # Add fake relationship to stored procedure table __PACKAGE__->has_one( @@ -402,7 +404,7 @@ sub check_for_errors { $errors{bodies} = _('No council selected') unless $self->bodies_str - && $self->bodies_str =~ m/^(?:-1|[\d,]+(?:\|[\d,]+)?)$/; + && $self->bodies_str =~ m/^(?:-1|[\d,]+)$/; if ( !$self->name || $self->name !~ m/\S/ ) { $errors{name} = _('Please enter your name'); @@ -450,8 +452,7 @@ sub confirm { sub bodies_str_ids { my $self = shift; return unless $self->bodies_str; - (my $bodies = $self->bodies_str) =~ s/\|.*$//; - my @bodies = split( /,/, $bodies ); + my @bodies = split( /,/, $self->bodies_str ); return \@bodies; } diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 0aa7c8b3a..da80e5b9c 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -320,15 +320,20 @@ sub send_reports { $cobrand->process_additional_metadata_for_email($row, \%h); } - # XXX Needs locks! - # XXX Only copes with at most one missing body - my ($bodies, $missing) = $row->bodies_str =~ /^([\d,]+)(?:\|(\d+))?/; - my @bodies = split(/,/, $bodies); - $bodies = FixMyStreet::App->model("DB::Body")->search( + my @bodies = split /,/, $row->bodies_str; + my $bodies = FixMyStreet::App->model("DB::Body")->search( { id => \@bodies }, { order_by => 'name' }, ); - $missing = FixMyStreet::App->model("DB::Body")->find($missing) if $missing; + + my $missing; + if ($row->bodies_missing) { + my @missing = FixMyStreet::App->model("DB::Body")->search( + { id => [ split /,/, $row->bodies_missing ] }, + { order_by => 'name' } + )->get_column('name')->all; + $missing = join(' / ', @missing) if @missing; + } my @dear; my %reporters = (); @@ -400,7 +405,7 @@ sub send_reports { $h{missing} = ''; if ($missing) { $h{missing} = '[ ' - . sprintf(_('We realise this problem might be the responsibility of %s; however, we don\'t currently have any contact details for them. If you know of an appropriate contact address, please do get in touch.'), $missing->name) + . sprintf(_('We realise this problem might be the responsibility of %s; however, we don\'t currently have any contact details for them. If you know of an appropriate contact address, please do get in touch.'), $missing) . " ]\n\n"; } |