diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-04-28 15:39:11 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-04-28 16:44:02 +0100 |
commit | e1605415077d30c1d5f86017486e74ebc498063a (patch) | |
tree | 6d24b6074f4ee40df0edb4530bc6ce404eb212d9 /perllib/FixMyStreet/App/Controller | |
parent | a0d40e1a354cfd6c53e97a5fc72001091d33a04f (diff) |
Only request needed join data in places.
The export flow and the admin search request more data
from the database than they need, which slows it down.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/Reports.pm | 8 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Dashboard.pm | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Reports.pm b/perllib/FixMyStreet/App/Controller/Admin/Reports.pm index ef9736ff6..7300fe676 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Reports.pm @@ -108,7 +108,8 @@ sub index : Path { my $problems = $c->cobrand->problems->search( $query, { - prefetch => 'user', + join => 'user', + '+columns' => 'user.email', rows => 50, order_by => $order, } @@ -150,8 +151,9 @@ sub index : Path { -or => $query, }, { - -select => [ 'me.*', qw/problem.bodies_str problem.state/ ], - prefetch => [qw/user problem/], + '+columns' => ['user.email'], + join => 'user', + prefetch => [qw/problem/], rows => 50, order_by => { -desc => 'me.id' } } diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index 27c8630f0..ad6c9ba98 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -349,7 +349,8 @@ sub export_as_csv : Private { my $csv = $c->stash->{csv} = { objects => $c->stash->{objects_rs}->search_rs({}, { - prefetch => 'comments', + join => 'comments', + '+columns' => ['comments.problem_state', 'comments.state', 'comments.confirmed', 'comments.mark_fixed'], order_by => ['me.confirmed', 'me.id'], cursor_page_size => 1000, }), |