Skip to content

Commit

Permalink
squash! [Bexley] Spot open container requests.
Browse files Browse the repository at this point in the history
Separate delivery/collection.
  • Loading branch information
dracos committed Nov 4, 2024
1 parent aaaacd3 commit e179c7a
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 37 deletions.
39 changes: 18 additions & 21 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -396,24 +396,20 @@ sub bin_services_for_address {
$filtered_service->{schedule} = 'Weekly';
}

my $report_details = $property->{open_reports}{missed}
{ $filtered_service->{service_id} };

if ($report_details) {
$filtered_service->{report_details} = $report_details;
$filtered_service->{report_open} = $report_details->{open};
} else {
$filtered_service->{report_open} = 0;
}

my $request_details = $property->{open_reports}{request}
{ $filtered_service->{service_id} };

if ($request_details) {
$filtered_service->{request_details} = $request_details;
$filtered_service->{requests_open} = $request_details->{open};
} else {
$filtered_service->{requests_open} = 0;
foreach (

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L399 was not covered by tests
{ type => 'missed', open => 'report_open', details => 'report_details' },
{ type => 'deliver', open => 'deliver_open', details => 'deliver_details' },
{ type => 'collect', open => 'collect_open', details => 'collect_details' },
) {
my $details = $property->{open_reports}{$_->{type}}
{ $filtered_service->{service_id} };

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L405 was not covered by tests

if ($details) {
$filtered_service->{$_->{details}} = $details;
$filtered_service->{$_->{open}} = $details->{open};

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

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Bexley/Waste.pm#L408-L409

Added lines #L408 - L409 were not covered by tests
} else {
$filtered_service->{$_->{open}} = 0;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L411 was not covered by tests
}
}

$filtered_service->{report_locked_out} = 0;
Expand Down Expand Up @@ -497,7 +493,8 @@ sub _open_reports {
unless $ws->{WorksheetStatusName} eq 'Open'
&& $ws->{WorksheetSubject} =~ /^Missed|Deliver|Collect/;

my $type = $ws->{WorksheetSubject} =~ /^Missed/ ? 'missed' : 'request';
my $type = $ws->{WorksheetSubject} =~ /^Missed/ ? 'missed'
: $ws->{WorksheetSubject} =~ /Deliver/ ? 'deliver' : 'collect';

# Check if it exists in our DB
my $external_id = 'Whitespace-' . $ws->{WorksheetID};
Expand Down Expand Up @@ -1332,7 +1329,7 @@ sub _construct_bin_request_form_delivery {
my $field_list = [];

my $property = $c->stash->{property};
my $open_reports = $property->{open_reports}{request};
my $open_reports = $property->{open_reports}{deliver};

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1332 was not covered by tests

for my $container ( @{ $property->{containers_for_delivery} } )
{
Expand Down Expand Up @@ -1407,7 +1404,7 @@ sub _construct_bin_request_form_removal {

my $field_list = [];

my $open_reports = $property->{open_reports}{request};
my $open_reports = $property->{open_reports}{collect};

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1407 was not covered by tests
my %service_names_to_ids
= map { $_->{service_name} => $_->{service_id} }
@{ $self->{c}->stash->{service_data} };
Expand Down
15 changes: 10 additions & 5 deletions t/app/controller/waste_bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ FixMyStreet::override_config {
round_schedule => 'RND-8-9 Mon, RND-8-9 Wed',
round => 'RND-8-9',
report_allowed => 0,
requests_open => 0,
deliver_open => 0,
collect_open => 0,
report_open => 1,
report_details => {
id => ignore(),
Expand All @@ -401,7 +402,8 @@ FixMyStreet::override_config {
round_schedule => 'RND-8-9 Mon, RND-8-9 Wed',
round => 'RND-8-9',
report_allowed => 0,
requests_open => 0,
deliver_open => 0,
collect_open => 0,
report_open => 1,
report_details => {
id => ignore(),
Expand All @@ -424,7 +426,8 @@ FixMyStreet::override_config {
round_schedule => 'RND-1 Tue Wk 1',
round => 'RND-1',
report_allowed => 0,
requests_open => 0,
deliver_open => 0,
collect_open => 0,
report_open => 0,
report_locked_out => 1,
report_locked_out_reason => 'Food - Not Out',
Expand All @@ -439,7 +442,8 @@ FixMyStreet::override_config {
round_schedule => 'RND-6 Wed Wk 2',
round => 'RND-6',
report_allowed => 1,
requests_open => 0,
deliver_open => 0,
collect_open => 0,
report_open => 0,
report_locked_out => 0,
report_locked_out_reason => '',
Expand All @@ -454,7 +458,8 @@ FixMyStreet::override_config {
round_schedule => 'RND-6 Wed Wk 2',
round => 'RND-6',
report_allowed => 1,
requests_open => 0,
deliver_open => 0,
collect_open => 0,
report_open => 0,
report_locked_out => 0,
report_locked_out_reason => '',
Expand Down
30 changes: 25 additions & 5 deletions t/app/controller/waste_bexley_container_requests.t
Original file line number Diff line number Diff line change
Expand Up @@ -1016,15 +1016,35 @@ FixMyStreet::override_config {
$open_container_request->update;

$mech->get_ok('/waste/10001');
$mech->content_contains("A white recycling box container request has been made");
$mech->content_contains("A white recycling box container delivery request has been made");
$mech->get_ok('/waste/10001/request?request_type=delivery');
$mech->submit_form_ok({ with_fields => { household_size => 2 } });
$mech->content_like(qr/name="container-PG-55"[^>]*disabled/, 'PG-55 option is disabled');
$mech->submit_form_ok( { with_fields => { 'container-Kitchen-5-Ltr-Caddy' => 1 } } );
$mech->content_like(
qr/name="container-PG-55-removal"[^>]*disabled/,
'PG-55 option is disabled for removals as well'
);
$mech->content_unlike(qr/name="container-PG-55-removal"[^>]*disabled/, 'PG-55 option is not disabled for removals');
$mech->get_ok('/waste/10001/request?request_type=removal');
$mech->content_unlike(qr/name="container-PG-55-removal"[^>]*disabled/, 'PG-55 removal is not disabled');

subtest 'Open collection request' => sub {
$whitespace_mock->mock( 'GetSiteWorksheets', sub{ [
{ WorksheetID => 'ABC',
WorksheetStatusName => 'Open',
WorksheetSubject => 'Collect a bin',
WorksheetStartDate => '',
WorksheetEscallatedDate => '',
},
] } );

$mech->get_ok('/waste/10001');
$mech->content_contains("A white recycling box container collection request has been made");
$mech->get_ok('/waste/10001/request?request_type=delivery');
$mech->submit_form_ok({ with_fields => { household_size => 2 } });
$mech->content_unlike(qr/name="container-PG-55"[^>]*disabled/, 'PG-55 option is not disabled');
$mech->submit_form_ok( { with_fields => { 'container-Kitchen-5-Ltr-Caddy' => 1 } } );
$mech->content_like(qr/name="container-PG-55-removal"[^>]*disabled/, 'PG-55 option is disabled for removals');
$mech->get_ok('/waste/10001/request?request_type=removal');
$mech->content_like(qr/name="container-PG-55-removal"[^>]*disabled/, 'PG-55 option is disabled');
};
};
};

Expand Down
24 changes: 18 additions & 6 deletions templates/web/bexley/waste/services.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
[% PROCESS 'waste/_services_header.html' %]
[% PROCESS 'waste/_service_missed.html' %]

[% IF unit.requests_open %]
[% IF unit.deliver_open %]
<span class="waste-service-descriptor">
A [% unit.service_name FILTER lower %] container request has been made. Check status below:
A [% unit.service_name FILTER lower %] container delivery request has been made. Check status below:
<ul>
<li>Reported on: [% unit.request_details.reported ? date.format(unit.request_details.reported) : 'N/A' %]</li>
<li>Will be completed by: [% unit.request_details.will_be_completed ? date.format(unit.request_details.will_be_completed) : 'N/A' %]</li>
<li>Action: [% unit.request_details.latest_comment %]</li>
<li>Reported on: [% unit.deliver_details.reported ? date.format(unit.deliver_details.reported) : 'N/A' %]</li>
<li>Will be completed by: [% unit.deliver_details.will_be_completed ? date.format(unit.deliver_details.will_be_completed) : 'N/A' %]</li>
<li>Action: [% unit.deliver_details.latest_comment %]</li>
</ul>
</span>
[% END %]

[% IF unit.collect_open %]
<span class="waste-service-descriptor">
A [% unit.service_name FILTER lower %] container collection request has been made. Check status below:
<ul>
<li>Reported on: [% unit.collect_details.reported ? date.format(unit.collect_details.reported) : 'N/A' %]</li>
<li>Will be completed by: [% unit.collect_details.will_be_completed ? date.format(unit.collect_details.will_be_completed) : 'N/A' %]</li>
<li>Action: [% unit.collect_details.latest_comment %]</li>
</ul>
</span>
[% END %]

[% ELSIF unit.delivery_allowed || unit.removal_allowed %]
[% IF unit.delivery_allowed || unit.removal_allowed %]
[% PROCESS 'waste/_services_request.html' %]
[% END %]

0 comments on commit e179c7a

Please sign in to comment.