aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311/PopulateServiceList.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-10-11 10:53:24 +0100
committerStruan Donald <struan@exo.org.uk>2011-10-11 10:53:24 +0100
commit7753f22870ffe99def9a7a61a9825b63b428eb91 (patch)
tree831df512d7ff129f28dba1b0a2f2c3386f9c8fec /perllib/Open311/PopulateServiceList.pm
parent7ddcddb27d0a3237e373757cbcc852974312a95a (diff)
do not die if we update a contact and there is one with the same category
Diffstat (limited to 'perllib/Open311/PopulateServiceList.pm')
-rw-r--r--perllib/Open311/PopulateServiceList.pm33
1 files changed, 20 insertions, 13 deletions
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm
index c232c4336..2dfe7e5c4 100644
--- a/perllib/Open311/PopulateServiceList.pm
+++ b/perllib/Open311/PopulateServiceList.pm
@@ -100,21 +100,29 @@ sub _handle_existing_contact {
my $service_name = $self->_normalize_service_name;
print $self->_current_council->area_id . " already has a contact for service code " . $self->_current_service->{service_code} . "\n";
- push @{ $self->found_contacts }, $self->_current_service->{service_code};
if ( $contact->deleted || $service_name ne $contact->category || $self->_current_service->{service_code} ne $contact->email ) {
- $contact->update(
- {
- category => $service_name,
- email => $self->_current_service->{service_code},
- confirmed => 1,
- deleted => 0,
- editor => $0,
- whenedited => \'ms_current_timestamp()',
- note => 'automatically undeleted by script',
- }
- );
+ eval {
+ $contact->update(
+ {
+ category => $service_name,
+ email => $self->_current_service->{service_code},
+ confirmed => 1,
+ deleted => 0,
+ editor => $0,
+ whenedited => \'ms_current_timestamp()',
+ note => 'automatically undeleted by script',
+ }
+ );
+ };
+
+ if ( $@ ) {
+ warn "Failed to update contact for service code " . $self->_current_service->{service_code} . " for council @{[$self->_current_council->area_id]}: $@\n";
+ return;
+ }
}
+
+ push @{ $self->found_contacts }, $self->_current_service->{service_code};
}
sub _create_contact {
@@ -122,7 +130,6 @@ sub _create_contact {
my $service_name = $self->_normalize_service_name;
- # FIXME - don't die if existing open311 category with same name
my $contact;
eval {
$contact = FixMyStreet::App->model( 'DB::Contact')->create(