diff options
-rw-r--r-- | bin/fetch-comments-24hs | 26 | ||||
-rw-r--r-- | conf/crontab.ugly | 4 | ||||
-rw-r--r-- | perllib/Open311/GetServiceRequestUpdates.pm | 8 |
3 files changed, 37 insertions, 1 deletions
diff --git a/bin/fetch-comments-24hs b/bin/fetch-comments-24hs new file mode 100644 index 000000000..b84f09ba7 --- /dev/null +++ b/bin/fetch-comments-24hs @@ -0,0 +1,26 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use DateTime; +use DateTime::Format::W3CDTF; +require 5.8.0; + +use FixMyStreet::App; +use CronFns; +my ($verbose, $nomail) = CronFns::options(); + +use Open311; +use Open311::GetServiceRequestUpdates; + +my $dt = DateTime->now(); +my $dt_24hrs_ago = $dt->clone; +$dt_24hrs_ago->add( hours => -24 ); + +my $updates = Open311::GetServiceRequestUpdates->new( + verbose => 1, + start_date => DateTime::Format::W3CDTF->format_datetime( $dt_24hrs_ago ), + end_date => DateTime::Format::W3CDTF->format_datetime( $dt ) +); + +$updates->fetch; diff --git a/conf/crontab.ugly b/conf/crontab.ugly index 68f00bee7..63f2bbdd9 100644 --- a/conf/crontab.ugly +++ b/conf/crontab.ugly @@ -29,7 +29,9 @@ MAILTO=!!(*= $user *)!!@mysociety.org 2 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-alerts.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper send-alerts" || echo "stalled?" 0,30 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-questionnaires.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper send-questionnaires" || echo "stalled?" 5,10,15,20,25,30,35,40,45,50,55 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/send-comments.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper send-comments" || echo "stalled?" -5,10,15,20,25,30,35,40,45,50,55 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/fetch-comments.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper fetch-comments" || echo "stalled?" +5,10,15,20,25,30,35,40,45,50,55 0,2-23 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/fetch-comments.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper fetch-comments" || echo "stalled?" +10,15,20,25,30,35,40,45,50,55 1 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/fetch-comments.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper fetch-comments" || echo "stalled?" +5 1 * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/fetch-comments.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper fetch-comments-24hs" || echo "stalled?" 0,30 * * * * !!(*= $user *)!! run-with-lockfile -n /data/vhost/!!(*= $vhost *)!!/open311-populate-service-list.lock "/data/vhost/!!(*= $vhost *)!!/fixmystreet/bin/cron-wrapper open311-populate-service-list" || echo "stalled?" !!(* } *)!! diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index 36d42bb3e..1f0852c96 100644 --- a/perllib/Open311/GetServiceRequestUpdates.pm +++ b/perllib/Open311/GetServiceRequestUpdates.pm @@ -54,6 +54,14 @@ 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 ); |