aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet/Comment.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2015-10-09 15:29:05 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-10-23 14:46:01 +0100
commit591c90a2ac4ea419a062bf19fffb0831d06786df (patch)
tree54a6d3245cde45525a9a88fc18ccb73c301eb6ed /perllib/FixMyStreet/DB/ResultSet/Comment.pm
parent97cd4dd5d39ee23a4c8f0863809e4230f954274a (diff)
Speed up admin front page.
* Don't show a categories summary unless asked via a link * Don't needlessly join in questionnaire/update summaries * Switch count(distinct()) to a subselect as it turns out select count(*) from (select distinct(user_id) from problem) temp; is a lot quicker than select count(distinct(user_id)) from problem;
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Comment.pm')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Comment.pm19
1 files changed, 10 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Comment.pm b/perllib/FixMyStreet/DB/ResultSet/Comment.pm
index 270501efc..1b6afb819 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Comment.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Comment.pm
@@ -32,15 +32,16 @@ sub timeline {
sub summary_count {
my ( $rs, $body_restriction ) = @_;
- return $rs->to_body($body_restriction)->search(
- undef,
- {
- group_by => ['me.state'],
- select => [ 'me.state', { count => 'me.id' } ],
- as => [qw/state state_count/],
- join => 'problem'
- }
- );
+ my $params = {
+ group_by => ['me.state'],
+ select => [ 'me.state', { count => 'me.id' } ],
+ as => [qw/state state_count/],
+ };
+ if ($body_restriction) {
+ $rs = $rs->to_body($body_restriction);
+ $params->{join} = 'problem';
+ }
+ return $rs->search(undef, $params);
}
1;