diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Reports.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 6b0d516a6..407fc625e 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -33,6 +33,7 @@ sub index : Path : Args(0) { # Zurich goes straight to map page, with all reports if ( $c->cobrand->moniker eq 'zurich' ) { + $c->forward( 'stash_report_filter_status' ); $c->forward( 'load_and_group_problems' ); my $pins = $c->stash->{pins}; $c->stash->{page} = 'reports'; @@ -121,7 +122,7 @@ sub ward : Path : Args(2) { $c->stash->{stats} = $c->cobrand->get_report_stats(); - my @categories = $c->stash->{body}->contacts->search( undef, { + my @categories = $c->stash->{body}->contacts->not_deleted->search( undef, { columns => [ 'category' ], distinct => 1, order_by => [ 'category' ], @@ -269,9 +270,7 @@ sub rss_ward : Path('/rss/reports') : Args(2) { # Problems sent to a council $c->stash->{type} = 'council_problems'; $c->stash->{title_params} = { COUNCIL => $c->stash->{body}->name }; - # XXX This looks up in both bodies_str and areas, but is only using body ID. - # This will not work properly in any install where body IDs are not === area IDs. - $c->stash->{db_params} = [ $c->stash->{body}->id, $c->stash->{body}->id ]; + $c->stash->{db_params} = [ $c->stash->{body}->id ]; } # Send on to the RSS generation @@ -396,20 +395,20 @@ sub load_and_group_problems : Private { my $not_open = [ FixMyStreet::DB::Result::Problem::fixed_states(), FixMyStreet::DB::Result::Problem::closed_states() ]; if ( $type eq 'new' ) { - $where->{confirmed} = { '>', \"ms_current_timestamp() - INTERVAL '4 week'" }; + $where->{confirmed} = { '>', \"current_timestamp - INTERVAL '4 week'" }; $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; } elsif ( $type eq 'older' ) { - $where->{confirmed} = { '<', \"ms_current_timestamp() - INTERVAL '4 week'" }; - $where->{lastupdate} = { '>', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{confirmed} = { '<', \"current_timestamp - INTERVAL '4 week'" }; + $where->{lastupdate} = { '>', \"current_timestamp - INTERVAL '8 week'" }; $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; } elsif ( $type eq 'unknown' ) { - $where->{lastupdate} = { '<', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{lastupdate} = { '<', \"current_timestamp - INTERVAL '8 week'" }; $where->{state} = { 'IN', [ FixMyStreet::DB::Result::Problem::open_states() ] }; } elsif ( $type eq 'fixed' ) { - $where->{lastupdate} = { '>', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{lastupdate} = { '>', \"current_timestamp - INTERVAL '8 week'" }; $where->{state} = $not_open; } elsif ( $type eq 'older_fixed' ) { - $where->{lastupdate} = { '<', \"ms_current_timestamp() - INTERVAL '8 week'" }; + $where->{lastupdate} = { '<', \"current_timestamp - INTERVAL '8 week'" }; $where->{state} = $not_open; } @@ -417,29 +416,16 @@ sub load_and_group_problems : Private { $where->{category} = $category; } + my $problems = $c->cobrand->problems; + if ($c->stash->{ward}) { $where->{areas} = { 'like', '%,' . $c->stash->{ward}->{id} . ',%' }; - $where->{bodies_str} = [ - undef, - $c->stash->{body}->id, - { 'like', $c->stash->{body}->id . ',%' }, - { 'like', '%,' . $c->stash->{body}->id }, - ]; + $problems = $problems->to_body($c->stash->{body}); } elsif ($c->stash->{body}) { - # XXX FixMyStreet used to have the following line so that reports not - # currently sent anywhere could still be listed in the appropriate - # (body/area), as they were the same. Now they're not, not sure if - # there's a way to do this easily. - #$where->{areas} = { 'like', '%,' . $c->stash->{body}->id . ',%' }; - $where->{bodies_str} = [ - # undef, - $c->stash->{body}->id, - { 'like', $c->stash->{body}->id . ',%' }, - { 'like', '%,' . $c->stash->{body}->id }, - ]; + $problems = $problems->to_body($c->stash->{body}); } - my $problems = $c->cobrand->problems->search( + $problems = $problems->search( $where, { order_by => $c->cobrand->reports_ordering, @@ -463,7 +449,6 @@ sub load_and_group_problems : Private { } } else { # Add to bodies it was sent to - # XXX Assumes body ID matches "council ID" my $bodies = $problem->bodies_str_ids; foreach ( @$bodies ) { next if $_ != $c->stash->{body}->id; @@ -507,6 +492,9 @@ sub stash_report_filter_status : Private { } elsif ( $status eq 'open' ) { $c->stash->{filter_status} = 'open'; $c->stash->{filter_problem_states} = FixMyStreet::DB::Result::Problem->open_states(); + } elsif ( $status eq 'closed' ) { + $c->stash->{filter_status} = 'closed'; + $c->stash->{filter_problem_states} = FixMyStreet::DB::Result::Problem->closed_states(); } elsif ( $status eq 'fixed' ) { $c->stash->{filter_status} = 'fixed'; $c->stash->{filter_problem_states} = FixMyStreet::DB::Result::Problem->fixed_states(); |