aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin/Stats.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Stats.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Stats.pm b/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
index 2860b3531..5f82094d6 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
@@ -72,4 +72,31 @@ sub questionnaire : Local : Args(0) {
return 1;
}
+sub refused : Local : Args(0) {
+ my ($self, $c) = @_;
+
+ my $contacts = $c->model('DB::Contact')->not_deleted->search([
+ { email => 'REFUSED' },
+ { 'body.can_be_devolved' => 1, 'me.send_method' => 'Refused' },
+ ], { prefetch => 'body' });
+ my %bodies;
+ while (my $contact = $contacts->next) {
+ my $body = $contact->body;
+ $bodies{$body->id}{body} = $body unless $bodies{$body->id}{body};
+ push @{$bodies{$body->id}{contacts}}, $contact;
+ }
+
+ my $bodies = $c->model('DB::Body')->search({ send_method => 'Refused' });
+ while (my $body = $bodies->next) {
+ $bodies{$body->id}{body} = $body;
+ $bodies{$body->id}{all} = 1;
+ }
+
+ my @bodies;
+ foreach (sort { $bodies{$a}{body}->name cmp $bodies{$b}{body}->name } keys %bodies) {
+ push @bodies, $bodies{$_};
+ }
+ $c->stash->{bodies} = \@bodies;
+}
+
1;