aboutsummaryrefslogtreecommitdiffstats
path: root/bin/send-reports
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-10-20 20:35:21 +0100
committerStruan Donald <struan@exo.org.uk>2011-10-20 20:35:21 +0100
commit6923018a0bdf4a996b2cf15a56ba887009e66aab (patch)
tree4b5d029faa478c3c6c3422a4eaf9a670560f7f69 /bin/send-reports
parente452ace27c4a13557a0ec878e74ebf19d1d1a347 (diff)
parent64cc9b22581f24acffbdae19ef6f06b96334135f (diff)
Merge branch 'open311-consumer'
Diffstat (limited to 'bin/send-reports')
-rwxr-xr-xbin/send-reports41
1 files changed, 38 insertions, 3 deletions
diff --git a/bin/send-reports b/bin/send-reports
index 173d78a52..b2820b750 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -27,6 +27,8 @@ use mySociety::EmailUtil;
use mySociety::MaPit;
use mySociety::Web qw(ent);
+use Open311;
+
# Set up site, language etc.
my ($verbose, $nomail) = CronFns::options();
my $base_url = mySociety::Config::get('BASE_URL');
@@ -39,7 +41,7 @@ my $unsent = FixMyStreet::App->model("DB::Problem")->search( {
} );
my (%notgot, %note);
while (my $row = $unsent->next) {
-
+
my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($row->cobrand)->new();
# Cobranded and non-cobranded messages can share a database. In this case, the conf file
@@ -75,7 +77,7 @@ while (my $row = $unsent->next) {
$h{fuzzy} = $row->used_map ? _('To view a map of the precise location of this issue')
: _('The user could not locate the problem on a map, but to see the area around the location they entered');
$h{closest_address} = '';
-
+
# If we are in the UK include eastings and northings, and nearest stuff
$h{easting_northing} = '';
if ( $cobrand->country eq 'GB' ) {
@@ -93,7 +95,7 @@ while (my $row = $unsent->next) {
$h{closest_address} = $cobrand->find_closest( $h{latitude}, $h{longitude} );
}
- my (@to, @recips, $template, $areas_info);
+ my (@to, @recips, $template, $areas_info, @open311_councils);
if ($site eq 'emptyhomes') {
my $council = $row->council;
@@ -135,6 +137,9 @@ while (my $row = $unsent->next) {
$h{category} = 'Customer Services' if $h{category} eq 'Other';
} elsif ($areas_info->{$council}->{type} eq 'LBO') { # London
$send_web = 'london';
+ } elsif ( my $endpoint = FixMyStreet::App->model("DB::Open311conf")->find( { area_id => $council } ) ) {
+ push @open311_councils, $endpoint;
+ $send_web = 'open311';
} else {
my $contact = FixMyStreet::App->model("DB::Contact")->find( {
deleted => 0,
@@ -247,6 +252,36 @@ while (my $row = $unsent->next) {
if (!$nomail) {
$result *= post_london_report( $row, %h );
}
+ } elsif ($send_web eq 'open311') {
+ foreach my $conf ( @open311_councils ) {
+ print 'posting to end point for ' . $conf->area_id . "\n" if $verbose;
+
+ my $contact = FixMyStreet::App->model("DB::Contact")->find( {
+ deleted => 0,
+ area_id => $conf->area_id,
+ category => $row->category
+ } );
+
+ my $open311 = Open311->new(
+ jurisdiction => $conf->jurisdiction,
+ endpoint => $conf->endpoint,
+ api_key => $conf->api_key,
+ );
+
+ # non standard west berks end points
+ if ( $row->council =~ /2619/ ) {
+ $open311->endpoints( { services => 'Services', requests => 'Requests' } );
+ }
+
+ my $resp = $open311->send_service_request( $row, \%h, $contact->email );
+
+ if ( $resp ) {
+ $row->external_id( $resp );
+ $result *= 0;
+ } else {
+ $result *= 1;
+ }
+ }
}
if ($result == mySociety::EmailUtil::EMAIL_SUCCESS) {