Skip to content

Commit

Permalink
[Bexley][WW] Add different messaging for attempted vs successful coll…
Browse files Browse the repository at this point in the history
…ection today
  • Loading branch information
nephila-nacrea authored and chrismytton committed Jun 3, 2024
1 parent cc253c0 commit c3ec368
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
30 changes: 16 additions & 14 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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' ) {
Expand All @@ -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 {
Expand All @@ -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
Expand Down
19 changes: 12 additions & 7 deletions t/app/controller/waste_bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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 {
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion templates/web/base/waste/bin_days.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ <h3 class="govuk-heading-l govuk-warning-text__heading">Your subscription is soo
<dd class="govuk-summary-list__value">
[% IF unit.next %]
[% IF unit.next.already_collected %]
<strong>Collection completed or attempted earlier today</strong>
[% IF unit.report_locked_out %]
<strong>Could not be collected today because it was red-tagged. See reason below.</strong>
[% ELSE %]
<strong>Reported as collected today</strong>
[% END %]
[% ELSIF unit.next.is_today %]
<strong>Being collected today</strong>
[% ELSE %]
Expand Down

0 comments on commit c3ec368

Please sign in to comment.