aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm3
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm31
-rw-r--r--templates/web/default/admin/index.html13
3 files changed, 44 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index abc454600..9fcb0c46d 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -60,6 +60,7 @@ sub index : Path : Args(0) {
$c->stash->{problems} = \%prob_counts;
$c->stash->{total_problems_live} =
$prob_counts{confirmed} + $prob_counts{fixed};
+ $c->stash->{total_problems_users} = $c->cobrand->problems->unique_users;
my $comments = $c->model('DB::Comment')->summary_count( $site_restriction );
@@ -106,6 +107,8 @@ sub index : Path : Args(0) {
: _('n/a');
$c->stash->{questionnaires} = \%questionnaire_counts;
+ $c->stash->{categories} = $c->cobrand->problems->categories_summary();
+
return 1;
}
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index b1b1e00a4..ca329ab59 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;
diff --git a/templates/web/default/admin/index.html b/templates/web/default/admin/index.html
index 59722a5ed..d1ed09114 100644
--- a/templates/web/default/admin/index.html
+++ b/templates/web/default/admin/index.html
@@ -11,7 +11,8 @@
[% END -%]
<ul>
- <li>[% tprintf( loc('<strong>%d</strong> live problems'), total_problems_live ) %]</li>
+ <li>[% tprintf( loc('<strong>%d</strong> live problems'), total_problems_live ) %];
+ [% tprintf( loc('from %d different users'), total_problems_users ) %]</li>
<li>[% tprintf( loc('%d live updates'), comments.confirmed || 0 ) %]</li>
<li>[% tprintf( loc('%d confirmed alerts, %d unconfirmed'), alerts.1, alerts.0) %]</li>
<li>[% tprintf( loc('%d questionnaires sent &ndash; %d answered (%s%%)'), questionnaires.total, questionnaires.1, questionnaires_pc) %]</li>
@@ -28,4 +29,14 @@
[% PROCESS states title=loc('Update breakdown by state') object=comments %]
+[% FOREACH category IN categories %]
+ [% IF loop.first %]
+ <h2>[% loc('Category fix rate for problems > 4 weeks old') %]</h2>
+ <table>
+ <tr><th>[% loc('Category') %]</th><th>[% loc('Total') %]</th><th>[% loc('Fixed') %]</th></tr>
+ [% END %]
+ <tr><td>[% category.key %]</td><td>[% category.value.total %]</td><td>[% category.value.fixed / category.value.total * 100 | format('%.1f') %]%</td></tr>
+ [% '</table>' IF loop.last %]
+[% END %]
+
[% INCLUDE 'admin/footer.html' %]