aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-10-04 10:12:19 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-10-04 10:12:19 +0100
commitaa83d4960f30abb98c7639de69bed11253aed7dc (patch)
treedfb03600c3d8c499f48eec7624299f7c73589094 /perllib/Open311
parent14b4877ce5f2f69fb91da9cd16dfe234605680b3 (diff)
Add warning option to Open311 populate, to show warnings.
Diffstat (limited to 'perllib/Open311')
-rw-r--r--perllib/Open311/PopulateServiceList.pm17
1 files changed, 10 insertions, 7 deletions
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm
index 39502f3b1..b12d68972 100644
--- a/perllib/Open311/PopulateServiceList.pm
+++ b/perllib/Open311/PopulateServiceList.pm
@@ -41,7 +41,8 @@ sub process_council {
my $list = $open311->get_service_list;
unless ( $list ) {
- warn "ERROR: no service list found for " . $self->_current_council->area_id . "\n";
+ warn "ERROR: no service list found for " . $self->_current_council->area_id . "\n"
+ if $self->verbose >= 1;
return;
}
$self->process_services( $list );
@@ -83,7 +84,7 @@ sub process_service {
$self->_current_service->{description} :
$self->_current_service->{service_name};
- print $self->_current_service->{service_code} . ': ' . $category . "\n" if $self->verbose;
+ print $self->_current_service->{service_code} . ': ' . $category . "\n" if $self->verbose >= 2;
my $contacts = FixMyStreet::App->model( 'DB::Contact')->search(
{
area_id => $self->_current_council->area_id,
@@ -123,7 +124,7 @@ 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" if $self->verbose;
+ print $self->_current_council->area_id . " already has a contact for service code " . $self->_current_service->{service_code} . "\n" if $self->verbose >= 2;
if ( $contact->deleted || $service_name ne $contact->category || $self->_current_service->{service_code} ne $contact->email ) {
eval {
@@ -141,7 +142,8 @@ sub _handle_existing_contact {
};
if ( $@ ) {
- warn "Failed to update contact for service code " . $self->_current_service->{service_code} . " for council @{[$self->_current_council->area_id]}: $@\n";
+ warn "Failed to update contact for service code " . $self->_current_service->{service_code} . " for council @{[$self->_current_council->area_id]}: $@\n"
+ if $self->verbose >= 1;
return;
}
}
@@ -171,7 +173,8 @@ sub _create_contact {
};
if ( $@ ) {
- warn "Failed to create contact for service code " . $self->_current_service->{service_code} . " for council @{[$self->_current_council->area_id]}: $@\n";
+ warn "Failed to create contact for service code " . $self->_current_service->{service_code} . " for council @{[$self->_current_council->area_id]}: $@\n"
+ if $self->verbose >= 1;
return;
}
@@ -181,14 +184,14 @@ sub _create_contact {
if ( $contact ) {
push @{ $self->found_contacts }, $self->_current_service->{service_code};
- print "created contact for service code " . $self->_current_service->{service_code} . " for council @{[$self->_current_council->area_id]}\n" if $self->verbose;
+ print "created contact for service code " . $self->_current_service->{service_code} . " for council @{[$self->_current_council->area_id]}\n" if $self->verbose >= 2;
}
}
sub _add_meta_to_contact {
my ( $self, $contact ) = @_;
- print "Fetching meta data for $self->_current_service->{service_code}\n" if $self->verbose;
+ print "Fetching meta data for $self->_current_service->{service_code}\n" if $self->verbose >= 2;
my $meta_data = $self->_current_open311->get_service_meta_info( $self->_current_service->{service_code} );
if ( ref $meta_data->{ attributes }->{ attribute } eq 'HASH' ) {