aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm6
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm35
-rw-r--r--perllib/Memcached.pm17
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm3
5 files changed, 25 insertions, 38 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 15a220644..037458538 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -413,6 +413,8 @@ sub summary : Private {
my ($self, $c) = @_;
my $dashboard = $c->forward('load_dashboard_data');
+ $c->log->info($c->user->email . ' viewed ' . $c->req->uri->path_query) if $c->user_exists;
+
eval {
my $data = path(FixMyStreet->path_to('../data/all-reports-dashboard.json'))->slurp_utf8;
$data = decode_json($data);
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index 591234877..6c826ec01 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -136,7 +136,7 @@ sub about_hook {
$c->stash->{form_name} = $c->get_param('name') || '';
$c->stash->{email} = $c->get_param('username') || '';
if ($c->user_exists) {
- my $body = _user_to_body($c);
+ my $body = $c->user->from_body || _user_to_body($c);
if ($body) {
$c->stash->{body} = $body;
$c->stash->{wards} = [ { name => 'summary' } ];
@@ -152,9 +152,7 @@ sub about_hook {
$c->stash->{template} = 'auth/general.html';
$c->detach('/auth/general');
} else {
- $c->stash->{no_body_found} = 1;
- $c->set_param('em', $email); # What the contact form wants
- $c->detach('/contact/submit');
+ $c->stash->{error} = 'bad_email';
}
}
}
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index ebc6e6c1b..e262cb63e 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -132,34 +132,25 @@ sub _recent {
};
my $probs;
- my $new = 0;
- if (defined $lat) {
- my $dist2 = $dist; # Create a copy of the variable to stop it being stringified into a locale in the next line!
- $key .= ":$lat:$lon:$dist2";
- $probs = Memcached::get($key);
- unless ($probs) {
- $attrs->{bind} = [ $lat, $lon, $dist ];
- $attrs->{join} = 'nearby';
- $probs = [ mySociety::Locale::in_gb_locale {
- $rs->search( $query, $attrs )->all;
- } ];
- $new = 1;
- }
+ if (defined $lat) { # No caching
+ $attrs->{bind} = [ $lat, $lon, $dist ];
+ $attrs->{join} = 'nearby';
+ $probs = [ mySociety::Locale::in_gb_locale {
+ $rs->search( $query, $attrs )->all;
+ } ];
} else {
$probs = Memcached::get($key);
- unless ($probs) {
+ if ($probs) {
+ # Need to reattach schema so that confirmed column gets reinflated.
+ $probs->[0]->result_source->schema( $rs->result_source->schema ) if $probs->[0];
+ # Catch any cached ones since hidden
+ $probs = [ grep { ! $_->is_hidden } @$probs ];
+ } else {
$probs = [ $rs->search( $query, $attrs )->all ];
- $new = 1;
+ Memcached::set($key, $probs, 3600);
}
}
- if ( $new ) {
- Memcached::set($key, $probs, 3600);
- } else {
- # Need to reattach schema so that confirmed column gets reinflated.
- $probs->[0]->result_source->schema( $rs->result_source->schema ) if $probs->[0];
- }
-
return $probs;
}
diff --git a/perllib/Memcached.pm b/perllib/Memcached.pm
index b612dd5ac..150594a01 100644
--- a/perllib/Memcached.pm
+++ b/perllib/Memcached.pm
@@ -4,39 +4,34 @@
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
-#
-# $Id: Memcached.pm,v 1.3 2008-10-10 15:57:28 matthew Exp $
-#
package Memcached;
use strict;
+use warnings;
use Cache::Memcached;
my ($memcache, $namespace);
sub set_namespace {
$namespace = shift;
- $namespace = 'fms' if $namespace eq 'fixmystreet';
}
-sub cache_connect {
- $memcache = new Cache::Memcached {
+sub instance {
+ return $memcache //= Cache::Memcached->new({
'servers' => [ '127.0.0.1:11211' ],
'namespace' => $namespace,
'debug' => 0,
'compress_threshold' => 10_000,
- };
+ });
}
sub get {
- cache_connect() unless $memcache;
- $memcache->get(@_);
+ instance->get(@_);
}
sub set {
- cache_connect() unless $memcache;
- $memcache->set(@_);
+ instance->set(@_);
}
1;
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index 661b039b0..cee1a629f 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -141,7 +141,8 @@ sub update_comments {
# if the comment is older than the last update
# do not change the status of the problem as it's
# tricky to determine the right thing to do.
- if ( $comment->created > $p->lastupdate ) {
+ # Allow the same time in case report/update created at same time (in external system)
+ if ( $comment->created >= $p->lastupdate ) {
# don't update state unless it's an allowed state and it's
# actually changing the state of the problem
if ( FixMyStreet::DB::Result::Problem->visible_states()->{$state} && $p->state ne $state &&