aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/Open311')
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm4
-rw-r--r--perllib/Open311/PopulateServiceList.pm19
2 files changed, 15 insertions, 8 deletions
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index 1f0852c96..656fa9d68 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -10,6 +10,7 @@ has system_user => ( is => 'rw' );
has start_date => ( is => 'ro', default => undef );
has end_date => ( is => 'ro', default => undef );
has suppress_alerts => ( is => 'rw', default => 0 );
+has verbose => ( is => 'ro', default => 0 );
sub fetch {
my $self = shift;
@@ -67,7 +68,8 @@ sub update_comments {
my $requests = $open311->get_service_request_updates( @args );
unless ( $open311->success ) {
- warn "Failed to fetch ServiceRequest Updates: " . $open311->error;
+ warn "Failed to fetch ServiceRequest Updates: " . $open311->error
+ if $self->verbose;
return 0;
}
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm
index 833aa4ee5..d8730a703 100644
--- a/perllib/Open311/PopulateServiceList.pm
+++ b/perllib/Open311/PopulateServiceList.pm
@@ -21,6 +21,7 @@ sub process_councils {
while ( my $council = $self->council_list->next ) {
next unless $council->endpoint;
+ next unless lc($council->send_method) eq 'open311';
$self->_current_council( $council );
$self->process_council;
}
@@ -40,7 +41,9 @@ sub process_council {
my $list = $open311->get_service_list;
unless ( $list ) {
- warn "ERROR: no service list found for " . $self->_current_council->area_id . "\n";
+ my $id = $self->_current_council->area_id;
+ warn "Council $id - http://mapit.mysociety.org/area/$id.html - did not return a service list\n"
+ if $self->verbose >= 1;
return;
}
$self->process_services( $list );
@@ -82,7 +85,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,
@@ -122,7 +125,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 {
@@ -140,7 +143,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;
}
}
@@ -176,7 +180,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;
}
@@ -186,14 +191,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' ) {