diff options
author | Struan Donald <struan@exo.org.uk> | 2011-06-07 17:34:08 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-06-07 17:34:08 +0100 |
commit | 5813d21b9ac8b358a557ab67722e8b54c769b663 (patch) | |
tree | d8d81597e1abf13855d27dd1b3a5353ca2f3240c /perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm | |
parent | 0f7de6563d4c96fa1ec9c429cca7e42259e25422 (diff) |
move summary count fetching out to result sets
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm index 1f5e26197..ab3acc388 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm @@ -130,4 +130,17 @@ sub timeline { ); } +sub summary_count { + my ( $rs, $restriction ) = @_; + + return $rs->search( + $restriction, + { + group_by => [ \'whenanswered is not null' ], + select => [ \'(whenanswered is not null)', { count => 'me.id' } ], + as => [qw/answered questionnaire_count/], + join => 'problem' + } + ); +} 1; |