diff options
author | Dave Arter <davea@mysociety.org> | 2017-10-31 15:29:35 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2017-12-05 09:56:30 +0000 |
commit | 2281b1eccb9c9ff8bc9b8644edc71ca8febda6c4 (patch) | |
tree | ecf23a7ba9ab9ece3a893d83ccf1054d63377177 /perllib/Open311/PopulateServiceList.pm | |
parent | 6c2290663217efd2aab807448b321868866e0bc5 (diff) |
Store group on Contacts in Open311 PopulateServiceList
Diffstat (limited to 'perllib/Open311/PopulateServiceList.pm')
-rw-r--r-- | perllib/Open311/PopulateServiceList.pm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index dbd0d1c68..e8d06efdf 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -156,7 +156,13 @@ sub _handle_existing_contact { if ( $contact and lc($metadata) eq 'true' ) { $self->_add_meta_to_contact( $contact ); } elsif ( $contact and $contact->extra and lc($metadata) eq 'false' ) { - $contact->update( { extra => undef } ); + $contact->set_extra_fields(); + $contact->update; + } + + if (my $group = $self->_current_service->{group}) { + $contact->set_extra_metadata(group => $group); + $contact->update; } push @{ $self->found_contacts }, $self->_current_service->{service_code}; @@ -182,6 +188,12 @@ sub _create_contact { ); }; + if (my $group = $self->_current_service->{group}) { + $contact->set_extra_metadata(group => $group); + $contact->update; + } + + if ( $@ ) { warn "Failed to create contact for service code " . $self->_current_service->{service_code} . " for body @{[$self->_current_body->id]}: $@\n" if $self->verbose >= 1; |