aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm7
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm17
-rw-r--r--perllib/FixMyStreet/Script/Alerts.pm2
-rw-r--r--perllib/FixMyStreet/TestAppProve.pm17
4 files changed, 36 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index 4f1727b1a..98e5f42b2 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -112,7 +112,7 @@ sub get_discovery : Private {
'changeset' => [$prod_changeset],
# XXX rewrite to match
'key_service' => ["Read access is open to all according to our \u003Ca href='/open_data' target='_blank'\u003Eopen data license\u003C/a\u003E. For write access either: 1. return the 'guid' cookie on each call (unique to each client) or 2. use an api key from a user account which can be generated here: http://seeclickfix.com/register The unversioned url will always point to the latest supported version."],
- 'max_requests' => [ $c->config->{RSS_LIMIT} ],
+ 'max_requests' => [ $c->config->{OPEN311_LIMIT} || 1000 ],
'endpoints' => [
{
'endpoint' => [
@@ -205,8 +205,9 @@ sub get_services : Private {
sub output_requests : Private {
my ( $self, $c, $criteria, $limit ) = @_;
- $limit = $c->config->{RSS_LIMIT}
- unless $limit && $limit <= $c->config->{RSS_LIMIT};
+ my $default_limit = $c->config->{OPEN311_LIMIT} || 1000;
+ $limit = $default_limit
+ unless $limit && $limit <= $default_limit;
my $attr = {
order_by => { -desc => 'confirmed' },
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 92865ace9..13a9c52cd 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -924,18 +924,29 @@ sub static_map {
if ($tile_url =~ m{^//}) {
$tile_url = "https:$tile_url";
}
- my $tile = LWP::Simple::get($tile_url);
+ my $tile;
+ if (FixMyStreet->test_mode) {
+ $tile = FixMyStreet->path_to('t/app/controller/sample.jpg')->slurp(iomode => '<:raw');
+ } else {
+ $tile = LWP::Simple::get($tile_url);
+ }
+ next unless $tile;
my $im = Image::Magick->new;
$im->BlobToImage($tile);
+ my $gravity = ($i<2?'North':'South') . ($i%2?'East':'West');
if (!$image) {
$image = $im;
- $image->Extent(geometry => '512x512', gravity => 'NorthWest');
+ $image->Extent(geometry => '512x512', gravity => $gravity);
} else {
- my $gravity = ($i<2?'North':'South') . ($i%2?'East':'West');
$image->Composite(image => $im, gravity => $gravity);
}
}
+ unless ($image) {
+ FixMyStreet::Map::set_map_class($orig_map_class) if $orig_map_class;
+ return;
+ }
+
# The only pin might be the report pin, with added x/y
my $pin = $map_data->{pins}->[0];
if ($pin) {
diff --git a/perllib/FixMyStreet/Script/Alerts.pm b/perllib/FixMyStreet/Script/Alerts.pm
index 91f5cd6ef..65183c09c 100644
--- a/perllib/FixMyStreet/Script/Alerts.pm
+++ b/perllib/FixMyStreet/Script/Alerts.pm
@@ -83,6 +83,8 @@ sub send() {
# this is for the new_updates alerts
next if $row->{non_public} and $row->{user_id} != $row->{alert_user_id};
+ next unless FixMyStreet::DB::Result::Problem::visible_states()->{$row->{state}};
+
$schema->resultset('AlertSent')->create( {
alert_id => $row->{alert_id},
parameter => $row->{item_id},
diff --git a/perllib/FixMyStreet/TestAppProve.pm b/perllib/FixMyStreet/TestAppProve.pm
index 75e9fe0a4..f2584fc33 100644
--- a/perllib/FixMyStreet/TestAppProve.pm
+++ b/perllib/FixMyStreet/TestAppProve.pm
@@ -2,6 +2,8 @@ use strict; use warnings;
package FixMyStreet::TestAppProve;
use App::Prove;
+use sigtrap qw(handler signal_handler normal-signals);
+
use YAML ();
use Path::Tiny 'path';
use Test::PostgreSQL;
@@ -18,6 +20,19 @@ see bin/run-tests for usage
=cut
+sub cleanup {
+ unlink "conf/general.test-autogenerated.$$.yml";
+}
+
+sub signal_handler {
+ cleanup();
+ exit(0);
+}
+
+END {
+ cleanup();
+}
+
sub run {
my ($class, @args) = @_;
local @ARGV = @args;
@@ -71,7 +86,7 @@ sub run {
$config->{FMS_DB_PASS} = '';
}
- my $config_out = 'general.test-autogenerated';
+ my $config_out = "general.test-autogenerated.$$";
path("conf/$config_out.yml")->spew( YAML::Dump($config) );
local $ENV{FMS_OVERRIDE_CONFIG} = $config_out;