Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bexley] Ignore duplicate log entries from Whitespace #5320

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@
my @property_logs;
my @street_logs;
my %completed_or_attempted_collections;
my %seen_logs;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L631 was not covered by tests

return ( \@property_logs, \@street_logs, \%completed_or_attempted_collections )
unless $cab_logs;
Expand All @@ -646,6 +647,13 @@
# Gather property-level and street-level exceptions
if ( $_->{Reason} && $_->{Reason} ne 'N/A' ) {
if ( $_->{Uprn} && $_->{Uprn} eq $property->{uprn} ) {
# Create a unique key for this log entry based on the actual event details
# using just the date portion of LogDate since multiple logs for the same
# event might have different timestamps on the same day
my $date_only = $logdate->ymd;
my $log_key = join(':', $_->{Reason}, $_->{RoundCode}, $date_only);

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

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L653-L654

Added lines #L653 - L654 were not covered by tests
next if $seen_logs{$log_key}++;

push @property_logs, {
uprn => $_->{Uprn},
round => $_->{RoundCode},
Expand Down
68 changes: 68 additions & 0 deletions t/app/controller/waste_bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,74 @@ FixMyStreet::override_config {
set_fixed_time('2024-03-31T02:00:00'); # March 31st, 02:00 BST
};

subtest 'Deduplication of in-cab logs' => sub {
$whitespace_mock->mock('GetInCabLogsByUsrn', sub {
return [
# Two logs with same reason, round code and date but different times
{
LogID => 1,
Reason => 'Refuse - Not Out',
RoundCode => 'RES-R3',
LogDate => '2024-04-01T10:02:15.7',
Uprn => '10001',
Usrn => '321',
},
{
LogID => 2,
Reason => 'Refuse - Not Out',
RoundCode => 'RES-R3',
LogDate => '2024-04-01T10:05:20.1',
Uprn => '10001',
Usrn => '321',
},
# Different date, should be included
{
LogID => 3,
Reason => 'Refuse - Not Out',
RoundCode => 'RES-R3',
LogDate => '2024-04-02T10:02:15.7',
Uprn => '10001',
Usrn => '321',
},
# Different reason, should be included
{
LogID => 4,
Reason => 'Food - Not Out',
RoundCode => 'RES-R3',
LogDate => '2024-04-01T10:02:15.7',
Uprn => '10001',
Usrn => '321',
},
# Different round code, should be included
{
LogID => 5,
Reason => 'Refuse - Not Out',
RoundCode => 'RES-R4',
LogDate => '2024-04-01T10:02:15.7',
Uprn => '10001',
Usrn => '321',
},
];
});

set_fixed_time('2024-04-03T12:00:00');
$mech->get_ok('/waste/10001');
$mech->content_contains('Service status');
$mech->content_contains('Our collection teams have reported the following problems with your bins:');

# Count occurrences of each type of message
my $content = $mech->content;
my $refuse_not_out_count = () = $content =~ /Refuse - Not Out/g;
my $food_not_out_count = () = $content =~ /Food - Not Out/g;

is($refuse_not_out_count, 3, "Shows three 'Refuse - Not Out' messages (two different dates, one different round)");
is($food_not_out_count, 1, "Shows one 'Food - Not Out' message");

# Reset mock and time
default_mocks();
set_fixed_time('2024-03-31T01:00:00');
};

subtest 'Missed enquiry form for properties with no collections' => sub {
$mech->delete_problems_for_body( $body->id );

Expand Down
Loading