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

[Brent] Check for 3rd contamination event. #5115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 6 additions & 26 deletions perllib/FixMyStreet/App/Form/Waste/Request/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ has_page replacement => (

return 'about_you' if $choice == $CONTAINER_CLEAR_SACK;
return 'how_long_lived' if $reason eq 'new_build';
return 'request_extra_refusal' if $reason eq 'extra' && $data->{ordered_previously};
# return 'request_extra_refusal' if $reason eq 'extra' && $data->{contamination_reports} >= 3;
return 'request_extra_refusal' if $reason eq 'extra' && ($data->{ordered_previously} || $data->{contamination_reports});
return 'about_you';
},
);
Expand Down Expand Up @@ -86,33 +85,14 @@ has_field request_reason => (
return unless $months;

my $events = $echo->GetEventsForObject(PointAddress => $c->stash->{property}{id}, 2936, $months);
$events = $c->cobrand->_parse_events($events, { include_closed_requests => 1 });
$events = $c->cobrand->_parse_events($events, { include_closed_events => 1 });
$saved_data->{ordered_previously} = $events->{request}{$choice} ? 1 : 0;

if ($value eq 'extra' || $value eq 'missing') {
my $services = $c->stash->{service_data};
my @tasks;
foreach (@$services) {
my $container = $_->{request_containers}->[0];
push @tasks, $_->{service_task_id} if $container == $choice;
}

# The below is not currently in use, FD-3672
# my $months = $refusal_contamination_months{$choice};
# my $end = DateTime->now->set_time_zone(FixMyStreet->local_time_zone)->truncate( to => 'day' );
# my $start = $end->clone->add(months => -$months);

# my $result = $echo->GetServiceTaskInstances($start, $end, @tasks);

# my $num = 0;
# foreach (@$result) {
# my $task_id = $_->{ServiceTaskRef}{Value}{anyType};
# my $tasks = Integrations::Echo::force_arrayref($_->{Instances}, 'ScheduledTaskInfo');
# foreach (@$tasks) {
# $num++ if ($_->{Resolution}||0) == 1148;
# }
# }
# $saved_data->{contamination_reports} = $num;
my $months = $refusal_contamination_months{$choice};
my $events = $echo->GetEventsForObject(PointAddress => $c->stash->{property}{id}, 2923, $months);
$events = $c->cobrand->_parse_events($events, { include_closed_events => 1 });
$saved_data->{contamination_reports} = $events->{enquiry}{2923} ? 1 : 0;
}
},
);
Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Cobrand/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ sub waste_munge_request_data {
sub request_referral {
my ($id, $data) = @_;

# return 1 if ($data->{contamination_reports} || 0) >= 3; # Will be present on missing only
return 1 if $data->{contamination_reports}; # Will be present on missing only
return 1 if ($data->{how_long_lived} || '') eq '3more'; # Will be present on new build only
return 1 if $data->{ordered_previously};
}
Expand Down
3 changes: 1 addition & 2 deletions perllib/FixMyStreet/Roles/Cobrand/Echo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,7 @@ sub _parse_events {

# Only care about open requests/enquiries
my $closed = $self->_closed_event($_);
next if $type eq 'request' && $closed && !$params->{include_closed_requests};
next if $type eq 'enquiry' && $closed;
next if ($type eq 'request' || $type eq 'enquiry') && $closed && !$params->{include_closed_events};

if ($type eq 'request') {
my $report = $self->problems->search({ external_id => $_->{Guid} })->first;
Expand Down
20 changes: 8 additions & 12 deletions t/cobrand/brent.t
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ FixMyStreet::override_config {
is $report->get_extra_field_value('request_referral'), $referral;
is $report->get_extra_field_value('request_how_long_lived'), $duration;
is $report->get_extra_field_value('request_ordered_previously'), $test_name eq 'Ordered' ? 1 : '';
is $report->get_extra_field_value('request_contamination_reports'), $test_name eq 'Contaminated' ? 3 : '';
is $report->get_extra_field_value('request_contamination_reports'), $test_name eq 'Contaminated' ? 1 : '';
FixMyStreet::Script::Reports::send();
my @email = $mech->get_email;
is @email, $emails;
Expand Down Expand Up @@ -1309,17 +1309,13 @@ FixMyStreet::override_config {
make_request("Not ordered", 'missing', '', '', 1);
make_request("Not ordered", 'extra', '', '', 1);

# $echo->mock('GetServiceTaskInstances', sub { [
# { ServiceTaskRef => { Value => { anyType => '401' } },
# Instances => { ScheduledTaskInfo => [
# { Resolution => 1148, CurrentScheduledDate => { DateTime => '2020-07-01T00:00:00Z' } },
# { Resolution => 1148, CurrentScheduledDate => { DateTime => '2020-07-01T00:00:00Z' } },
# { Resolution => 1148, CurrentScheduledDate => { DateTime => '2020-07-01T00:00:00Z' } },
# ] }
# },
# ] });
# make_request("Contaminated", 'missing', '', 1, 2);
# make_request("Contaminated", 'extra', '', 'refuse');
$echo->mock('GetEventsForObject', sub { [ {
Guid => 'b-guid',
EventTypeId => 2923,
ResolvedDate => { DateTime => '2024-05-17T12:00:00Z' },
} ] } );
make_request("Contaminated", 'missing', '', 1, 2);
make_request("Contaminated", 'extra', '', 'refuse');
};

subtest 'test staff-only assisted collection form' => sub {
Expand Down
Loading