aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm49
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Bodies.pm5
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Stats.pm46
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Status.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm9
6 files changed, 64 insertions, 49 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index f3d1b2e63..038cba9e5 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -61,12 +61,15 @@ Displays some summary information for the requests.
sub index : Path : Args(0) {
my ( $self, $c ) = @_;
- if ($c->cobrand->moniker eq 'zurich' && $c->stash->{admin_type} ne 'super') {
- return $c->cobrand->admin();
+ if ($c->cobrand->moniker eq 'zurich') {
+ if ($c->stash->{admin_type} eq 'super') {
+ $c->forward('/admin/stats/gather');
+ return 1;
+ } else {
+ return $c->cobrand->admin();
+ }
}
- $c->forward('/admin/stats/state');
-
my @unsent = $c->cobrand->problems->search( {
state => [ FixMyStreet::DB::Result::Problem::open_states() ],
whensent => undef,
@@ -79,44 +82,6 @@ sub index : Path : Args(0) {
} )->all;
$c->stash->{unsent_reports} = \@unsent;
- my $alerts = $c->model('DB::Alert')->summary_report_alerts( $c->cobrand->restriction );
-
- my %alert_counts =
- map { $_->confirmed => $_->get_column('confirmed_count') } $alerts->all;
-
- $alert_counts{0} ||= 0;
- $alert_counts{1} ||= 0;
-
- $c->stash->{alerts} = \%alert_counts;
-
- my $contacts = $c->model('DB::Contact')->summary_count();
-
- my %contact_counts =
- map { $_->state => $_->get_column('state_count') } $contacts->all;
-
- $contact_counts{confirmed} ||= 0;
- $contact_counts{unconfirmed} ||= 0;
- $contact_counts{total} = $contact_counts{confirmed} + $contact_counts{unconfirmed};
-
- $c->stash->{contacts} = \%contact_counts;
-
- my $questionnaires = $c->model('DB::Questionnaire')->summary_count( $c->cobrand->restriction );
-
- my %questionnaire_counts = map {
- $_->get_column('answered') => $_->get_column('questionnaire_count')
- } $questionnaires->all;
- $questionnaire_counts{1} ||= 0;
- $questionnaire_counts{0} ||= 0;
-
- $questionnaire_counts{total} =
- $questionnaire_counts{0} + $questionnaire_counts{1};
- $c->stash->{questionnaires_pc} =
- $questionnaire_counts{total}
- ? sprintf( '%.1f',
- $questionnaire_counts{1} / $questionnaire_counts{total} * 100 )
- : _('n/a');
- $c->stash->{questionnaires} = \%questionnaire_counts;
-
$c->forward('fetch_all_bodies');
return 1;
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm
index 4bfca21ae..6ae068cd9 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm
@@ -272,6 +272,11 @@ sub update_contact : Private {
} else {
$contact->unset_extra_metadata( 'photo_required' );
}
+ if ( $c->get_param('open311_protect') ) {
+ $contact->set_extra_metadata( open311_protect => 1 );
+ } else {
+ $contact->unset_extra_metadata( 'open311_protect' );
+ }
if ( my @group = $c->get_param_list('group') ) {
@group = grep { $_ } @group;
if (scalar @group == 0) {
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Stats.pm b/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
index 5f82094d6..03b529a55 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
@@ -7,6 +7,52 @@ BEGIN { extends 'Catalyst::Controller'; }
sub index : Path : Args(0) {
my ( $self, $c ) = @_;
return $c->cobrand->admin_stats() if $c->cobrand->moniker eq 'zurich';
+ $c->forward('gather');
+}
+
+sub gather : Private {
+ my ($self, $c) = @_;
+
+ $c->forward('state'); # Problem/update stats used on that page
+ $c->forward('/admin/fetch_all_bodies'); # For body stat
+
+ my $alerts = $c->model('DB::Alert')->summary_report_alerts( $c->cobrand->restriction );
+
+ my %alert_counts =
+ map { $_->confirmed => $_->get_column('confirmed_count') } $alerts->all;
+
+ $alert_counts{0} ||= 0;
+ $alert_counts{1} ||= 0;
+
+ $c->stash->{alerts} = \%alert_counts;
+
+ my $contacts = $c->model('DB::Contact')->summary_count();
+
+ my %contact_counts =
+ map { $_->state => $_->get_column('state_count') } $contacts->all;
+
+ $contact_counts{confirmed} ||= 0;
+ $contact_counts{unconfirmed} ||= 0;
+ $contact_counts{total} = $contact_counts{confirmed} + $contact_counts{unconfirmed};
+
+ $c->stash->{contacts} = \%contact_counts;
+
+ my $questionnaires = $c->model('DB::Questionnaire')->summary_count( $c->cobrand->restriction );
+
+ my %questionnaire_counts = map {
+ $_->get_column('answered') => $_->get_column('questionnaire_count')
+ } $questionnaires->all;
+ $questionnaire_counts{1} ||= 0;
+ $questionnaire_counts{0} ||= 0;
+
+ $questionnaire_counts{total} =
+ $questionnaire_counts{0} + $questionnaire_counts{1};
+ $c->stash->{questionnaires_pc} =
+ $questionnaire_counts{total}
+ ? sprintf( '%.1f',
+ $questionnaire_counts{1} / $questionnaire_counts{total} * 100 )
+ : _('n/a');
+ $c->stash->{questionnaires} = \%questionnaire_counts;
}
sub state : Local : Args(0) {
diff --git a/perllib/FixMyStreet/App/Controller/Status.pm b/perllib/FixMyStreet/App/Controller/Status.pm
index 57c8f362e..e56a7930a 100755
--- a/perllib/FixMyStreet/App/Controller/Status.pm
+++ b/perllib/FixMyStreet/App/Controller/Status.pm
@@ -31,7 +31,7 @@ sub index : Path : Args(0) {
# superusers. It doesn't have anything sensitive
$c->stash->{admin_type} = 'super';
# Fetch summary stats from admin front page
- $c->forward('/admin/index');
+ $c->forward('/admin/stats/gather');
# Fetch git version
$c->forward('/admin/config_page');
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 290f46d9e..21dd2d455 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -279,6 +279,8 @@ sub admin_allow_user {
return $user->from_body->areas->{$self->council_area_id};
}
+sub admin_show_creation_graph { 0 }
+
sub available_permissions {
my $self = shift;
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 5b2079831..3e48170d8 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -241,12 +241,9 @@ sub unique_users {
return $rs->search( {
state => [ FixMyStreet::DB::Result::Problem->visible_states() ],
}, {
- select => [ { distinct => 'user_id' } ],
- as => [ 'user_id' ]
- } )->as_subselect_rs->search( undef, {
- select => [ { count => 'user_id' } ],
- as => [ 'count' ]
- } )->first->get_column('count');
+ columns => [ 'user_id' ],
+ distinct => 1,
+ } );
}
sub categories_summary {