diff options
Diffstat (limited to 'bin/oxfordshire')
-rwxr-xr-x | bin/oxfordshire/archive-old-enquiries | 29 | ||||
-rwxr-xr-x | bin/oxfordshire/open311_service_request_update.cgi | 2 | ||||
-rw-r--r-- | bin/oxfordshire/open311_services.pm | 16 |
3 files changed, 46 insertions, 1 deletions
diff --git a/bin/oxfordshire/archive-old-enquiries b/bin/oxfordshire/archive-old-enquiries new file mode 100755 index 000000000..7fe66703a --- /dev/null +++ b/bin/oxfordshire/archive-old-enquiries @@ -0,0 +1,29 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +require 5.8.0; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../../setenv.pl"; +} + +use FixMyStreet::Script::ArchiveOldEnquiries; +use Getopt::Long::Descriptive; + +my ($opts, $usage) = describe_options( + '%c %o', + ['commit|c', "actually close reports and send emails. Omitting this flag will do a dry-run"], + ['body|b=s', "which body ID to close reports for"], + ['cobrand=s', "which cobrand template to use for sent emails"], + ['closure-cutoff=s', "Anything before this will be closed with no email"], + ['email-cutoff=s', "Anything before this will be closed with an email sent to the reporter"], + ['limit|l=s', "limit to a certain number of reports/users to be closed"], + ['help|h', "print usage message and exit" ], +); +print($usage->text), exit if $opts->help; + +FixMyStreet::Script::ArchiveOldEnquiries::archive($opts); diff --git a/bin/oxfordshire/open311_service_request_update.cgi b/bin/oxfordshire/open311_service_request_update.cgi index 87b14fb98..8fb190e0e 100755 --- a/bin/oxfordshire/open311_service_request_update.cgi +++ b/bin/oxfordshire/open311_service_request_update.cgi @@ -102,7 +102,7 @@ XML foreach my $row(@{$ary_ref}) { if (defined $row) { my ($id, $service_req_id, $updated_at, $status, $desc) = map { prepare_for_xml($_) } @$row; - $updated_at=~s/(\d{4}-\d\d-\d\d) (\d\d:\d\d:\d\d)/${1}T${2}Z/; # for now assume OCC in Zulu time + $updated_at = get_utc_iso8601_string($updated_at); # value from the DB is in server-local time, convert to UTC. $xml.= <<XML; <request_update> <update_id>$id</update_id> diff --git a/bin/oxfordshire/open311_services.pm b/bin/oxfordshire/open311_services.pm index 12d0754fa..9be598751 100644 --- a/bin/oxfordshire/open311_services.pm +++ b/bin/oxfordshire/open311_services.pm @@ -10,6 +10,8 @@ use CGI; use Encode qw(from_to); use DBI; use Time::Piece; +use Time::Local qw(timelocal); +use POSIX qw(strftime); ################################################################### @@ -145,6 +147,20 @@ sub get_date_or_nothing { return $d; } +#------------------------------------------------------------------ +# get_utc_iso8601_string +# Takes a local date/time string and converts it to UTC, returning +# a ISO8601-format string. +# expected format: YYYY-MM-DD HH:MM:SS +# e.g.: 2016-04-01 13:37:42 -> 2016-04-01T12:37:42Z +#------------------------------------------------------------------ +sub get_utc_iso8601_string { + my $datetime = shift; + $datetime =~ s{(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)}{ + strftime "%Y-%m-%dT%H:%M:%SZ", gmtime(timelocal($6, $5, $4, $3, int($2)-1, int($1)-1900)); + }e; + return $datetime; +} 1; |