From c3ec368edb7610f2c616327d33391d78d91329aa Mon Sep 17 00:00:00 2001 From: Victoria Mihell-Hale Date: Fri, 31 May 2024 19:19:52 +0100 Subject: [PATCH] [Bexley][WW] Add different messaging for attempted vs successful collection today --- perllib/FixMyStreet/Cobrand/Bexley/Waste.pm | 30 +++++++++++---------- t/app/controller/waste_bexley.t | 19 ++++++++----- templates/web/base/waste/bin_days.html | 6 ++++- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/perllib/FixMyStreet/Cobrand/Bexley/Waste.pm b/perllib/FixMyStreet/Cobrand/Bexley/Waste.pm index 0ef819036f4..db53b2e58ab 100644 --- a/perllib/FixMyStreet/Cobrand/Bexley/Waste.pm +++ b/perllib/FixMyStreet/Cobrand/Bexley/Waste.pm @@ -209,9 +209,10 @@ sub bin_services_for_address { = $self->_missed_collection_reports($property); $property->{recent_collections} = $self->_recent_collections($property); - my ( $property_logs, $street_logs, $successful_collections ) + my ( $property_logs, $street_logs, $completed_or_attempted_collections ) = $self->_in_cab_logs($property); - $property->{successful_collections} = $successful_collections; + $property->{completed_or_attempted_collections} + = $completed_or_attempted_collections; $property->{red_tags} = $property_logs; $property->{service_updates} = $street_logs; @@ -265,10 +266,10 @@ sub bin_services_for_address { # 'Next collection date' could be today; successful collection logs # will tell us if the collection has already been made - my $successful_collection_dt - = $property->{successful_collections}{$round}; - my $collected_today = $successful_collection_dt - && $now_dt->delta_days($successful_collection_dt) + my $completed_or_attempted_collection_dt + = $property->{completed_or_attempted_collections}{$round}; + my $collected_today = $completed_or_attempted_collection_dt + && $now_dt->delta_days($completed_or_attempted_collection_dt) ->in_units('days') == 0 ? 1 : 0; @@ -510,9 +511,9 @@ sub _in_cab_logs { my @property_logs; my @street_logs; - my %successful_collections; + my %completed_or_attempted_collections; - return ( \@property_logs, \@street_logs, \%successful_collections ) + return ( \@property_logs, \@street_logs, \%completed_or_attempted_collections ) unless $cab_logs; for (@$cab_logs) { @@ -522,9 +523,9 @@ sub _in_cab_logs { # log against a round code should be taken as a sign that the round # has been completed or at least attempted for the property. # Overwrite entry for given round if a later logdate is found. - $successful_collections{ $_->{RoundCode} } = $logdate - if !$successful_collections{ $_->{RoundCode} } - || $successful_collections{ $_->{RoundCode} } < $logdate; + $completed_or_attempted_collections{ $_->{RoundCode} } = $logdate + if !$completed_or_attempted_collections{ $_->{RoundCode} } + || $completed_or_attempted_collections{ $_->{RoundCode} } < $logdate; # Gather property-level and street-level exceptions if ( $_->{Reason} && $_->{Reason} ne 'N/A' ) { @@ -547,7 +548,8 @@ sub _in_cab_logs { } } - return ( \@property_logs, \@street_logs, \%successful_collections ); + return ( \@property_logs, \@street_logs, + \%completed_or_attempted_collections ); } sub can_report_missed { @@ -573,14 +575,14 @@ sub can_report_missed { if ($last_expected_collection_dt) { # TODO We can probably get successful collections directly off the # property rather than query _in_cab_logs again - my ( undef, undef, $successful_collections ) + my ( undef, undef, $completed_or_attempted_collections ) = $self->_in_cab_logs($property); # If there is a log for this collection, that is when # the round was completed so we can make a report if # we're within that time my $logged_time_for_round - = $successful_collections->{ $service->{round} }; + = $completed_or_attempted_collections->{ $service->{round} }; # log time needs to be greater than or equal to 3 working days ago, # less than today diff --git a/t/app/controller/waste_bexley.t b/t/app/controller/waste_bexley.t index 13b49230ab6..213a6d80357 100644 --- a/t/app/controller/waste_bexley.t +++ b/t/app/controller/waste_bexley.t @@ -459,7 +459,8 @@ FixMyStreet::override_config { $mech->get_ok('/waste/10001'); $mech->content_lacks('Service status'); $mech->content_contains('Being collected today'); - $mech->content_lacks('Collection completed or attempted earlier today'); + $mech->content_lacks('Reported as collected today'); + $mech->content_lacks('Could not be collected today because it was red-tagged. See reason below.'); # Set time to later in the day set_fixed_time('2024-04-01T16:01:00'); # April 1st, 17:01 BST @@ -480,14 +481,15 @@ FixMyStreet::override_config { $mech->get_ok('/waste/10001'); $mech->content_lacks('Service status'); $mech->content_lacks('Being collected today'); - $mech->content_contains('Collection completed or attempted earlier today'); + $mech->content_contains('Reported as collected today'); + $mech->content_lacks('Could not be collected today because it was red-tagged. See reason below.'); note 'Property has red tag on collection attempted earlier today'; $whitespace_mock->mock( 'GetInCabLogsByUsrn', sub { return [ { LogID => 1, - Reason => 'Bin has gone feral', + Reason => 'Paper & Card - Bin has gone feral', RoundCode => 'RND-8-9', LogDate => '2024-04-01T12:00:00.417', Uprn => '10001', @@ -501,14 +503,15 @@ FixMyStreet::override_config { 'Our collection teams have reported the following problems with your bins:' ); $mech->content_lacks('Being collected today'); - $mech->content_contains('Collection completed or attempted earlier today'); + $mech->content_lacks('Reported as collected today'); + $mech->content_contains('Could not be collected today because it was red-tagged. See reason below.'); note 'Red tag on other property on same street'; $whitespace_mock->mock( 'GetInCabLogsByUsrn', sub { return [ { LogID => 1, - Reason => 'Bin has gone feral', + Reason => 'Paper & Card - Bin has gone feral', RoundCode => 'RND-8-9', LogDate => '2024-04-01T12:00:00.417', Uprn => '19991', @@ -519,7 +522,8 @@ FixMyStreet::override_config { $mech->get_ok('/waste/10001'); $mech->content_lacks('Service status'); $mech->content_lacks('Being collected today'); - $mech->content_contains('Collection completed or attempted earlier today'); + $mech->content_contains('Reported as collected today'); + $mech->content_lacks('Could not be collected today because it was red-tagged. See reason below.'); note 'Service update on street'; $whitespace_mock->mock( 'GetInCabLogsByUsrn', sub { @@ -541,7 +545,8 @@ FixMyStreet::override_config { 'Our collection teams have reported the following problems with your bins:' ); $mech->content_lacks('Being collected today'); - $mech->content_contains('Collection completed or attempted earlier today'); + $mech->content_contains('Reported as collected today'); + $mech->content_lacks('Could not be collected today because it was red-tagged. See reason below.'); # Reinstate original mocks set_fixed_time('2024-03-31T01:00:00'); # March 31st, 02:00 BST diff --git a/templates/web/base/waste/bin_days.html b/templates/web/base/waste/bin_days.html index a1f3c1a1a92..c97158f103e 100644 --- a/templates/web/base/waste/bin_days.html +++ b/templates/web/base/waste/bin_days.html @@ -121,7 +121,11 @@

Your subscription is soo
[% IF unit.next %] [% IF unit.next.already_collected %] - Collection completed or attempted earlier today + [% IF unit.report_locked_out %] + Could not be collected today because it was red-tagged. See reason below. + [% ELSE %] + Reported as collected today + [% END %] [% ELSIF unit.next.is_today %] Being collected today [% ELSE %]