Skip to content

Commit

Permalink
[Bexley] Allow missed collection reports on day of collection
Browse files Browse the repository at this point in the history
Update the logic which checks we're outside the reporting window to
check if the collection is happening today, and if it is then proceed
with the missed collection checks.
  • Loading branch information
chrismytton committed May 14, 2024
1 parent 10c84d5 commit 1774f1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 4 additions & 7 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,10 @@ sub can_report_missed {
my $now_dt

Check warning on line 443 in perllib/FixMyStreet/Cobrand/Bexley/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L443

Added line #L443 was not covered by tests
= DateTime->now( time_zone => FixMyStreet->local_time_zone );

# For collections with prefix RCY- or PG- we need to check if the last
# collection was made over WORKING_DAYS_WINDOW ago because some
# collections are weekly and some fortnightly, but they share a round
# code prefix.
if ( $service->{round} =~ /^RCY-/ or $service->{round} =~ /^PG-/ ) {
return 0 if $last_expected_collection_dt < $min_dt;
}
# We need to check if the last collection was made over
# WORKING_DAYS_WINDOW ago because some collections are weekly and some
# fortnightly, but they share a round code prefix.
return 0 if $last_expected_collection_dt < $min_dt && !$service->{next}->{is_today};

return ( $log_for_round->{date} < $now_dt
&& $log_for_round->{date} >= $min_dt ) ? 1 : 0
Expand Down
6 changes: 6 additions & 0 deletions t/app/controller/waste_bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ FixMyStreet::override_config {
service_id => 'FO-140',
round => 'RCY-R2',
round_schedule => 'RCY-R2 Mon',
next => {
is_today => 1,
},
},
# Collection due last working day but it did not happen
'RES-180' => {
Expand Down Expand Up @@ -548,6 +551,8 @@ FixMyStreet::override_config {
'RES-R4 Fri' => DateTime->today->subtract( days => 3 ), # RES-240
'GDN-R1 Tue' => DateTime->today->subtract( days => 6 ), # GA-240
'RCY-R2 Mon PG Wk 2' => DateTime->today->subtract( days => 7 ), # PG-240
'RCY-R1 Mon' => DateTime->today->subtract( days => 14 ), # FO-23
'RCY-R2 Mon' => DateTime->today->subtract( days => 14 ), # FO-140
},
};

Expand Down Expand Up @@ -620,6 +625,7 @@ FixMyStreet::override_config {

is $cobrand->can_report_missed( $property, $services{'PG-240'} ), 0,
'cannot report missed collection against service whose round was collected more than 3 working days ago';
ok !$services{'PG-240'}{last}{is_delayed}, 'not marked delayed';

# Put time back to previous value
set_fixed_time('2024-03-31T01:00:00'); # March 31st, 02:00 BST
Expand Down

0 comments on commit 1774f1f

Please sign in to comment.