aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-03-19 18:08:47 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-03-19 18:14:54 +0000
commitd7a335a1002bf3e17bd19e034b9ee263ea623685 (patch)
treef7f3652357dff4e08e37403f317441620f0d50c7
parent130c0bf25f3ef8a9dda89c2aa3febb497f23a2c2 (diff)
[Zurich] Prefetch report users, cache body lookups
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm5
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm3
2 files changed, 6 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index c8af63987..453300cd5 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -1172,11 +1172,12 @@ sub admin_stats {
sub export_as_csv {
my ($self, $c, $params) = @_;
+ $c->model('DB')->schema->storage->sql_maker->quote_char('"');
my $csv = $c->stash->{csv} = {
problems => $c->model('DB::Problem')->search_rs(
$params,
{
- join => 'admin_log_entries',
+ join => ['admin_log_entries', 'user'],
distinct => 1,
columns => [
'id', 'created',
@@ -1190,6 +1191,7 @@ sub export_as_csv {
'service',
'extra',
{ sum_time_spent => { sum => 'admin_log_entries.time_spent' } },
+ 'name', 'user.id', 'user.email', 'user.phone', 'user.name',
]
}
),
@@ -1258,6 +1260,7 @@ sub export_as_csv {
filename => 'stats',
};
$c->forward('/dashboard/generate_csv');
+ $c->model('DB')->schema->storage->sql_maker->quote_char('');
}
sub problem_confirm_email_extras {
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 9feb98c76..fac0fc7ef 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -653,7 +653,8 @@ sub body {
my $body;
if ($problem->external_body) {
if ($problem->cobrand eq 'zurich') {
- $body = $c->model('DB::Body')->find({ id => $problem->external_body });
+ my $cache = $problem->result_source->schema->cache;
+ return $cache->{bodies}{$problem->external_body} //= $c->model('DB::Body')->find({ id => $problem->external_body });
} else {
$body = $problem->external_body;
}