diff options
author | Struan Donald <struan@exo.org.uk> | 2011-07-26 16:57:08 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-07-26 16:57:08 +0100 |
commit | 54066cd1387643dd6c6cb3040c520bee66881fd7 (patch) | |
tree | eda84b3f347220ed12de3aa690116148287891bd /perllib/FixMyStreet/DB/ResultSet/Problem.pm | |
parent | 8146bad18eeaab658871dd28eb38199a5d068395 (diff) | |
parent | 198fcef62892fe0b2fbb3ea8a080fca87843445e (diff) |
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet into new_statuses
Conflicts:
perllib/FixMyStreet/App/Controller/Admin.pm
perllib/FixMyStreet/App/Controller/JSON.pm
perllib/FixMyStreet/Map/Tilma/Original.pm
web/css/core.css
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Problem.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Problem.pm | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm index 4de8f2e5f..89f17fa60 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm @@ -161,10 +161,10 @@ sub timeline { } sub summary_count { - my ( $rs, $restriction ) = @_; + my ( $rs ) = @_; return $rs->search( - $restriction, + undef, { group_by => ['state'], select => [ 'state', { count => 'id' } ], @@ -173,4 +173,31 @@ sub summary_count { ); } +sub unique_users { + my ( $rs ) = @_; + + return $rs->search( { + state => [ 'confirmed', 'fixed' ], + }, { + select => [ { count => { distinct => 'user_id' } } ], + as => [ 'count' ] + } )->first->get_column('count'); +} + +sub categories_summary { + my ( $rs ) = @_; + + my $categories = $rs->search( { + state => [ 'confirmed', 'fixed' ], + whensent => { '<' => \"NOW() - INTERVAL '4 weeks'" }, + }, { + select => [ 'category', { count => 'id' }, { count => \"case when state='fixed' then 1 else null end" } ], + as => [ 'category', 'c', 'fixed' ], + group_by => [ 'category' ], + result_class => 'DBIx::Class::ResultClass::HashRefInflator' + } ); + my %categories = map { $_->{category} => { total => $_->{c}, fixed => $_->{fixed} } } $categories->all; + return \%categories; +} + 1; |