diff options
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/Hounslow.pm')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Hounslow.pm | 86 |
1 files changed, 51 insertions, 35 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Hounslow.pm b/perllib/FixMyStreet/Cobrand/Hounslow.pm index 2fc949546..90d3b17dc 100644 --- a/perllib/FixMyStreet/Cobrand/Hounslow.pm +++ b/perllib/FixMyStreet/Cobrand/Hounslow.pm @@ -65,8 +65,14 @@ sub categories_restriction { # Email categories with a devolved send_method, so can identify Open311 # categories as those which have a blank send_method. return $rs->search({ - 'me.send_method' => undef, 'body.name' => [ 'Hounslow Borough Council', 'Highways England' ], + -or => [ + 'me.send_method' => undef, + 'me.category' => { -in => [ + 'Pavement Overcrowding', + 'Streetspace Suggestions and Feedback', + ] }, + ], }); } @@ -120,40 +126,25 @@ sub open311_skip_report_fetch { sub filter_report_description { "" } sub setup_general_enquiries_stash { - my $self = shift; - - my @bodies = $self->{c}->model('DB::Body')->active->for_areas(( $self->council_area_id ))->all; - my %bodies = map { $_->id => $_ } @bodies; - my @contacts # - = $self->{c} # - ->model('DB::Contact') # - ->active - ->search( - { - 'me.body_id' => [ keys %bodies ] - }, - { - prefetch => 'body', - order_by => 'me.category', - } - )->all; - @contacts = grep { - my $group = $_->get_extra_metadata('group') || ''; - $group eq 'Other' || $group eq 'General Enquiries'; - } @contacts; - $self->{c}->stash->{bodies} = \%bodies; - $self->{c}->stash->{bodies_to_list} = \%bodies; - $self->{c}->stash->{contacts} = \@contacts; - $self->{c}->stash->{missing_details_bodies} = []; - $self->{c}->stash->{missing_details_body_names} = []; - - $self->{c}->set_param('title', "General Enquiry"); - # Can't use (0, 0) for lat lon so default to the rough location - # of Hounslow Highways HQ. - $self->{c}->stash->{latitude} = 51.469; - $self->{c}->stash->{longitude} = -0.35; - - return 1; + my $self = shift; + my $c = $self->{c}; + + $c->set_param('title', "General Enquiry"); + # Can't use (0, 0) for lat lon so default to the rough location + # of Hounslow Highways HQ. + $c->stash->{latitude} = 51.469; + $c->stash->{longitude} = -0.35; + + $c->stash->{all_areas} = { $self->council_area_id => { id => $self->council_area_id } }; + $c->forward('/report/new/setup_categories_and_bodies'); + + my $contacts = $c->stash->{contacts}; + @$contacts = grep { + my $groups = $_->groups; + grep { $_ eq 'Other' || $_ eq 'General Enquiries' } @$groups; + } @$contacts; + + return 1; } sub abuse_reports_only { 1 } @@ -171,4 +162,29 @@ sub lookup_site_code_config { { # their cobrand at all. sub cut_off_date { '2019-05-06' } +sub front_stats_data { + my ( $self ) = @_; + + my $recency = '1 week'; + my $shorter_recency = '3 days'; + + my $completed = $self->problems->recent_completed(); + my $updates = $self->problems->number_comments(); + my $new = $self->problems->recent_new( $recency ); + + if ( $new > $completed ) { + $recency = $shorter_recency; + $new = $self->problems->recent_new( $recency ); + } + + my $stats = { + completed => $completed, + updates => $updates, + new => $new, + recency => $recency, + }; + + return $stats; +} + 1; |