aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fetch-reports6
-rwxr-xr-xbin/fetch-reports-24hs35
-rwxr-xr-xbin/send-comments13
3 files changed, 50 insertions, 4 deletions
diff --git a/bin/fetch-reports b/bin/fetch-reports
index 665b4aff0..20de10f4b 100755
--- a/bin/fetch-reports
+++ b/bin/fetch-reports
@@ -1,8 +1,8 @@
#!/usr/bin/env perl
#
-# This script utilises the Open311 extension explained at
-# https://github.com/mysociety/FixMyStreet/wiki/Open311-FMS---Proposed-differences-to-Open311
-# to fetch updates on service requests.
+# This script utilises Open311 as described at
+# http://wiki.open311.org/GeoReport_v2/#get-service-requests
+# to fetch service requests.
use strict;
use warnings;
diff --git a/bin/fetch-reports-24hs b/bin/fetch-reports-24hs
new file mode 100755
index 000000000..ec0eabc2e
--- /dev/null
+++ b/bin/fetch-reports-24hs
@@ -0,0 +1,35 @@
+#!/usr/bin/env perl
+#
+# This script utilises Open311 as described at
+# http://wiki.open311.org/GeoReport_v2/#get-service-requests
+# to fetch service requests.
+
+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 DateTime;
+
+use CronFns;
+my ($verbose, $nomail) = CronFns::options();
+
+use Open311::GetServiceRequests;
+
+my $dt = DateTime->now();
+my $dt_24hrs_ago = $dt->clone;
+$dt_24hrs_ago->add( hours => -24 );
+
+my $reports = Open311::GetServiceRequests->new(
+ verbose => 1,
+ start_date => $dt_24hrs_ago,
+ end_date => $dt
+);
+
+$reports->fetch;
diff --git a/bin/send-comments b/bin/send-comments
index aecedcb08..4293417f5 100755
--- a/bin/send-comments
+++ b/bin/send-comments
@@ -100,7 +100,18 @@ while ( my $body = $bodies->next ) {
}
while ( my $comment = $comments->next ) {
- my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($comment->cobrand)->new();
+ my $cobrand = $body->get_cobrand_handler ||
+ FixMyStreet::Cobrand->get_class_for_moniker($comment->cobrand)->new();
+
+ # Some cobrands (e.g. Buckinghamshire) don't want to receive updates
+ # from anyone except the original problem reporter.
+ if ($cobrand->call_hook(should_skip_sending_update => $comment)) {
+ unless (defined $comment->get_extra_metadata('cobrand_skipped_sending')) {
+ $comment->set_extra_metadata(cobrand_skipped_sending => 1);
+ $comment->update;
+ }
+ next;
+ }
# TODO actually this should be OK for any devolved endpoint if original Open311->can_be_devolved, presumably
if ( 0 ) { # Check can_be_devolved and do this properly if set