aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2018-06-07 13:28:45 +0200
committerMarius Halden <marius.h@lden.org>2018-06-07 13:28:45 +0200
commit956f8b8a065824f9a9dc379eba1d0aa8b1b669cf (patch)
tree49f9ccb147b18dddee97500d4df7a3fb3dd3737c /perllib/FixMyStreet/App/Controller/Admin/Stats.pm
parent782457d016084c8de04989dbc824a71899f8b41b (diff)
parent4dbf5371f79c5f290c08e561ba2c881e96b58669 (diff)
Merge tag 'v2.3.3' into fiksgatami-dev
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;