Skip to content

Commit

Permalink
[Bexley][Whitespace] Use combination of LogID + Reason for unique logs
Browse files Browse the repository at this point in the history
LogID isn't unique, a report of Food - Not Out and Paper & Card - Not
Out results in two log entries which both have the same LogID, but
different reasons, so use the reason when making logs unique.

Also adds an extra check to ensure the round matches when looking for
relevant logs.
  • Loading branch information
chrismytton committed May 22, 2024
1 parent a932199 commit 6d20a13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ sub bin_services_for_address {
$filtered_service->{report_locked_out_reason} = '';
my $log_reason_prefix = $self->get_in_cab_logs_reason_prefix($filtered_service->{service_id});
if ($log_reason_prefix) {
my @relevant_logs = grep { $_->{reason} =~ /^$log_reason_prefix/ } @$property_logs;
my @relevant_logs = grep { $_->{reason} =~ /^$log_reason_prefix/ && $_->{round} eq $filtered_service->{round} } @$property_logs;
if (@relevant_logs) {
$filtered_service->{report_locked_out} = 1;
$filtered_service->{report_locked_out_reason} = $relevant_logs[0]->{reason};
Expand Down Expand Up @@ -381,9 +381,9 @@ sub _in_cab_logs {

$cab_logs = [ @$cab_logs_uprn, @$cab_logs_usrn ];

# Make cab logs unique by LogID
# Make cab logs unique by LogID and Reason
my %seen;
@$cab_logs = grep { !$seen{ $_->{LogID} }++ } @$cab_logs;
@$cab_logs = grep { !$seen{ $_->{LogID} . $_->{Reason} }++ } @$cab_logs;

$self->{c}->stash->{cab_logs} = $cab_logs;
} else {
Expand Down
2 changes: 1 addition & 1 deletion t/app/controller/waste_bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ sub _in_cab_logs {
Usrn => '321',
},
{
LogID => 2,
LogID => 1,
Reason => 'N/A',
RoundCode => 'RND-6',
LogDate => '2024-03-28T06:10:09.417',
Expand Down

0 comments on commit 6d20a13

Please sign in to comment.