diff options
author | Struan Donald <struan@exo.org.uk> | 2012-04-23 14:33:51 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-04-23 14:33:51 +0100 |
commit | 071bad4732338dde88758cdd0c67b02ad1dbf23b (patch) | |
tree | d50ecd588e2030d1fb6794688d7f7162ae3af331 | |
parent | aea3028f78f81ab1fd89ce46ad6abbe4aa0717ee (diff) |
add verbose option and apply to print statements
-rw-r--r-- | perllib/Open311/PopulateServiceList.pm | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index 3723b178e..59148be7b 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -8,6 +8,7 @@ use Open311; has council_list => ( is => 'ro' ); has found_contacts => ( is => 'rw', default => sub { [] } ); +has verbose => ( is => 'ro', default => 0 ); has _current_council => ( is => 'rw' ); has _current_open311 => ( is => 'rw' ); @@ -81,7 +82,7 @@ sub process_service { $self->_current_service->{description} : $self->_current_service->{service_name}; - print $self->_current_service->{service_code} . ': ' . $category . "\n"; + print $self->_current_service->{service_code} . ': ' . $category . "\n" if $self->verbose; my $contacts = FixMyStreet::App->model( 'DB::Contact')->search( { area_id => $self->_current_council->area_id, @@ -121,7 +122,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"; + print $self->_current_council->area_id . " already has a contact for service code " . $self->_current_service->{service_code} . "\n" if $self->verbose; if ( $contact->deleted || $service_name ne $contact->category || $self->_current_service->{service_code} ne $contact->email ) { eval { @@ -179,14 +180,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"; + print "created contact for service code " . $self->_current_service->{service_code} . " for council @{[$self->_current_council->area_id]}\n" if $self->verbose; } } sub _add_meta_to_contact { my ( $self, $contact ) = @_; - print "Fetching meta data for $self->_current_service->{service_code}\n"; + print "Fetching meta data for $self->_current_service->{service_code}\n" if $self->verbose; my $meta_data = $self->_current_open311->get_service_meta_info( $self->_current_service->{service_code} ); if ( ref $meta_data->{ attributes }->{ attribute } eq 'HASH' ) { |