diff options
Diffstat (limited to 'perllib/Open311/GetServiceRequestUpdates.pm')
-rw-r--r-- | perllib/Open311/GetServiceRequestUpdates.pm | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index 99e1d5758..e337c0f57 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; @@ -31,6 +32,13 @@ sub fetch { jurisdiction => $council->jurisdiction, ); + if ( $council->area_id =~ /2482/ ) { + my $endpoints = $o->endpoints; + $endpoints->{update} = 'update.xml'; + $endpoints->{service_request_updates} = 'update.xml'; + $o->endpoints( $endpoints ); + } + $self->suppress_alerts( $council->suppress_alerts ); $self->system_user( $council->comment_user ); $self->update_comments( $o, { areaid => $council->area_id }, ); @@ -47,12 +55,21 @@ sub update_comments { push @args, $self->start_date; push @args, $self->end_date; + # default to asking for last 2 hours worth if not Bromley + } elsif ( $council_details->{areaid} != 2482 ) { + my $end_dt = DateTime->now(); + my $start_dt = $end_dt->clone; + $start_dt->add( hours => -2 ); + + push @args, DateTime::Format::W3CDTF->format_datetime( $start_dt ); + push @args, DateTime::Format::W3CDTF->format_datetime( $end_dt ); } 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 for " . $council_details->{areaid} . ":\n" . $open311->error + if $self->verbose; return 0; } |