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.pm83
1 files changed, 1 insertions, 82 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Stats.pm b/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
index 35e150890..2860b3531 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Stats.pm
@@ -6,88 +6,7 @@ BEGIN { extends 'Catalyst::Controller'; }
sub index : Path : Args(0) {
my ( $self, $c ) = @_;
-
- my $selected_body;
- if ( $c->user->is_superuser ) {
- $c->forward('/admin/fetch_all_bodies');
- $selected_body = $c->get_param('body');
- } else {
- $selected_body = $c->user->from_body->id;
- }
-
- if ( $c->cobrand->moniker eq 'zurich' ) {
- return $c->cobrand->admin_stats();
- }
-
- if ( $c->get_param('getcounts') ) {
-
- my ( $start_date, $end_date, @errors );
- my $parser = DateTime::Format::Strptime->new( pattern => '%d/%m/%Y' );
-
- $start_date = $parser-> parse_datetime ( $c->get_param('start_date') );
-
- push @errors, _('Invalid start date') unless defined $start_date;
-
- $end_date = $parser-> parse_datetime ( $c->get_param('end_date') ) ;
-
- push @errors, _('Invalid end date') unless defined $end_date;
-
- $c->stash->{errors} = \@errors;
- $c->stash->{start_date} = $start_date;
- $c->stash->{end_date} = $end_date;
-
- $c->stash->{unconfirmed} = $c->get_param('unconfirmed') eq 'on' ? 1 : 0;
-
- return 1 if @errors;
-
- my $bymonth = $c->get_param('bymonth');
- $c->stash->{bymonth} = $bymonth;
-
- $c->stash->{selected_body} = $selected_body;
-
- my $field = 'confirmed';
-
- $field = 'created' if $c->get_param('unconfirmed');
-
- my $one_day = DateTime::Duration->new( days => 1 );
-
-
- my %select = (
- select => [ 'state', { 'count' => 'me.id' } ],
- as => [qw/state count/],
- group_by => [ 'state' ],
- order_by => [ 'state' ],
- );
-
- if ( $c->get_param('bymonth') ) {
- %select = (
- select => [
- { extract => \"year from $field", -as => 'c_year' },
- { extract => \"month from $field", -as => 'c_month' },
- { 'count' => 'me.id' }
- ],
- as => [qw/c_year c_month count/],
- group_by => [qw/c_year c_month/],
- order_by => [qw/c_year c_month/],
- );
- }
-
- my $p = $c->cobrand->problems->to_body($selected_body)->search(
- {
- -AND => [
- $field => { '>=', $start_date},
- $field => { '<=', $end_date + $one_day },
- ],
- },
- \%select,
- );
-
- # in case the total_report count is 0
- $c->stash->{show_count} = 1;
- $c->stash->{states} = $p;
- }
-
- return 1;
+ return $c->cobrand->admin_stats() if $c->cobrand->moniker eq 'zurich';
}
sub state : Local : Args(0) {