Skip to content

Commit

Permalink
[Bexley][WW] Use USRN logs only
Browse files Browse the repository at this point in the history
  • Loading branch information
nephila-nacrea authored and chrismytton committed Jun 3, 2024
1 parent 8cefb7e commit cc253c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
19 changes: 6 additions & 13 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -492,23 +492,16 @@ sub _in_cab_logs {
my $dt_from = $self->_subtract_working_days(WORKING_DAYS_WINDOW);
my $cab_logs;
if ( !$self->{c}->stash->{cab_logs} ) {
my $cab_logs_uprn = $self->whitespace->GetInCabLogsByUprn(
$property->{uprn},
$dt_from->stringify,
);

my $cab_logs_usrn
# Property should always have a USRN, but return UPRN logs in case not
$cab_logs
= $property->{usrn}
? $self->whitespace->GetInCabLogsByUsrn(
$property->{usrn},
$dt_from->stringify,
) : [];

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

# Make cab logs unique by LogID and Reason
my %seen;
@$cab_logs = grep { !$seen{ $_->{LogID} . $_->{Reason} }++ } @$cab_logs;
) : $self->whitespace->GetInCabLogsByUprn(
$property->{uprn},
$dt_from->stringify,
);

$self->{c}->stash->{cab_logs} = $cab_logs;
} else {
Expand Down
10 changes: 1 addition & 9 deletions t/app/controller/waste_bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ sub default_mocks {
return _site_collections()->{$uprn};
}
);
$whitespace_mock->mock( 'GetInCabLogsByUprn', sub {
my ( $self, $uprn ) = @_;
return [ grep { $_->{Uprn} eq $uprn } @{ _in_cab_logs() } ];
});
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub {
my ( $self, $usrn ) = @_;
return _in_cab_logs();
Expand Down Expand Up @@ -455,7 +451,6 @@ FixMyStreet::override_config {
},
];
} );
$whitespace_mock->mock( 'GetInCabLogsByUprn', sub { [] } );
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub { [] } );

set_fixed_time('2024-04-01T07:00:00'); # April 1st, 08:00 BST
Expand Down Expand Up @@ -488,7 +483,7 @@ FixMyStreet::override_config {
$mech->content_contains('Collection completed or attempted earlier today');

note 'Property has red tag on collection attempted earlier today';
$whitespace_mock->mock( 'GetInCabLogsByUprn', sub {
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub {
return [
{
LogID => 1,
Expand All @@ -500,7 +495,6 @@ FixMyStreet::override_config {
},
];
});
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub { [] } );
$mech->get_ok('/waste/10001');
$mech->content_contains('Service status');
$mech->content_contains(
Expand All @@ -510,7 +504,6 @@ FixMyStreet::override_config {
$mech->content_contains('Collection completed or attempted earlier today');

note 'Red tag on other property on same street';
$whitespace_mock->mock( 'GetInCabLogsByUprn', sub { [] } );
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub {
return [
{
Expand All @@ -529,7 +522,6 @@ FixMyStreet::override_config {
$mech->content_contains('Collection completed or attempted earlier today');

note 'Service update on street';
$whitespace_mock->mock( 'GetInCabLogsByUprn', sub { [] } );
$whitespace_mock->mock( 'GetInCabLogsByUsrn', sub {
return [
{
Expand Down

0 comments on commit cc253c0

Please sign in to comment.