aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-03-20 17:46:15 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-03-21 14:34:39 +0000
commit129de99f4c042cf9f9cb4a25cc3f5bb5c40077c3 (patch)
tree06b6719072832e3b14d3b760f3c9d3809511f4dd /perllib/FixMyStreet
parentbe61e9162a225323e5840227980b45cc16cdd497 (diff)
[fixmystreet.com] Add admin page to list refused.
Diffstat (limited to 'perllib/FixMyStreet')
-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;