aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorM Somerville <matthew-github@dracos.co.uk>2020-11-04 13:45:20 +0000
committerM Somerville <matthew-github@dracos.co.uk>2020-11-11 10:37:44 +0000
commit5e2f1b3509391f891955db8b8fe05dbf40b7a041 (patch)
tree8bc4f1fd87a12e8191ee8b80df87f5d5ecc146c1
parent3f70d1f0b4d543072eda2d1b59092a5b9e6b3253 (diff)
[Bromley] Adapt if last instance is in future.
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm13
-rw-r--r--perllib/Integrations/Echo.pm29
-rw-r--r--t/cobrand/bromley.t2
-rw-r--r--templates/web/base/waste/bin_days.html7
4 files changed, 37 insertions, 14 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index f80bdaa12..fc41eae28 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -695,10 +695,21 @@ sub _parse_schedules {
my $last = $schedule->{LastInstance};
$d = construct_bin_date($last->{CurrentScheduledDate});
- if ($d && (!$max_last || $d > $max_last->{date})) {
+ # It is possible the last instance for this schedule has been rescheduled to
+ # be in the future. If so, we should treat it like it is a next instance.
+ if ($d && $d->strftime("%F") gt $today && (!$min_next || $d < $min_next->{date})) {
+ my $last_changed = $last->{CurrentScheduledDate}{DateTime} ne $last->{OriginalScheduledDate}{DateTime};
+ $min_next = {
+ date => $d,
+ ordinal => ordinal($d->day),
+ changed => $last_changed,
+ };
+ } elsif ($d && (!$max_last || $d > $max_last->{date})) {
+ my $last_changed = $last->{CurrentScheduledDate}{DateTime} ne $last->{OriginalScheduledDate}{DateTime};
$max_last = {
date => $d,
ordinal => ordinal($d->day),
+ changed => $last_changed,
ref => $last->{Ref}{Value}{anyType},
};
}
diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm
index 28dd1e9bc..bf4b453e6 100644
--- a/perllib/Integrations/Echo.pm
+++ b/perllib/Integrations/Echo.pm
@@ -89,25 +89,31 @@ sub GetTasks {
push @refs, \%a;
}
- return [
- {
+ if ($self->sample_data) {
+ my %lookup = map { $_->[0] . ',' . $_->[1] => 1 } @_;
+ my $data = [];
+ push @$data, {
Ref => { Value => { anyType => [ 123, 456 ] } },
State => { Name => 'Completed' },
Resolution => { Ref => { Value => { anyType => 187 } }, Name => 'Wrong Bin Out' },
TaskTypeId => 3216,
CompletedDate => { DateTime => '2020-05-27T10:00:00Z' }
- },
- {
+ } if $lookup{"123,456"};
+ push @$data, {
Ref => { Value => { anyType => [ 234, 567 ] } },
State => { Name => 'Outstanding' },
CompletedDate => undef
- },
- {
+ } if $lookup{"234,567"};
+ push @$data, {
Ref => { Value => { anyType => [ 345, 678 ] } },
State => { Name => 'Not Completed' }
- },
- { Ref => { Value => { anyType => [ 456, 789 ] } }, CompletedDate => undef },
- ] if $self->sample_data;
+ } if $lookup{"345,678"};
+ push @$data, {
+ Ref => { Value => { anyType => [ 456, 789 ] } },
+ CompletedDate => undef
+ } if $lookup{"456,789"};
+ return $data;
+ }
# This creates XML of the form <taskRefs><ObjectRef>...</ObjectRef><ObjectRef>...</ObjectRef>...</taskRefs>
# uncoverable statement
@@ -188,6 +194,7 @@ sub GetServiceUnitsForObject {
OriginalScheduledDate => { DateTime => '2020-06-03T00:00:00Z' },
},
LastInstance => {
+ OriginalScheduledDate => { DateTime => '2020-05-27T00:00:00Z' },
CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' },
Ref => { Value => { anyType => [ 123, 456 ] } },
},
@@ -207,6 +214,7 @@ sub GetServiceUnitsForObject {
OriginalScheduledDate => { DateTime => '2020-06-10T00:00:00Z' },
},
LastInstance => {
+ OriginalScheduledDate => { DateTime => '2020-05-27T00:00:00Z' },
CurrentScheduledDate => { DateTime => '2020-05-27T00:00:00Z' },
Ref => { Value => { anyType => [ 234, 567 ] } },
},
@@ -226,6 +234,7 @@ sub GetServiceUnitsForObject {
OriginalScheduledDate => { DateTime => '2020-06-03T00:00:00Z' },
},
LastInstance => {
+ OriginalScheduledDate => { DateTime => '2020-05-18T00:00:00Z' },
CurrentScheduledDate => { DateTime => '2020-05-20T00:00:00Z' },
Ref => { Value => { anyType => [ 345, 678 ] } },
},
@@ -241,6 +250,7 @@ sub GetServiceUnitsForObject {
ServiceTaskSchedules => { ServiceTaskSchedule => [ {
EndDate => { DateTime => '2020-01-01T00:00:00Z' },
LastInstance => {
+ OriginalScheduledDate => { DateTime => '2019-12-31T00:00:00Z' },
CurrentScheduledDate => { DateTime => '2019-12-31T00:00:00Z' },
},
}, {
@@ -250,6 +260,7 @@ sub GetServiceUnitsForObject {
OriginalScheduledDate => { DateTime => '2020-06-01T00:00:00Z' },
},
LastInstance => {
+ OriginalScheduledDate => { DateTime => '2020-05-18T00:00:00Z' },
CurrentScheduledDate => { DateTime => '2020-05-18T00:00:00Z' },
Ref => { Value => { anyType => [ 456, 789 ] } },
},
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index fb34f1b6d..13f4f2308 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -271,6 +271,7 @@ FixMyStreet::override_config {
subtest 'test open enquiries' => sub {
set_fixed_time('2020-05-19T12:00:00Z'); # After sample food waste collection
$mech->get_ok('/waste/uprn/12345');
+ $mech->content_like(qr/Mixed Recycling.*?Next collection<\/dt>\s*<dd[^>]*>\s*Wednesday, 20th May\s+\(this collection has been adjusted/s);
$mech->follow_link_ok({ text => 'Report a problem with a food waste collection' });
$mech->content_contains('Waste spillage');
$mech->content_lacks('Gate not closed');
@@ -280,6 +281,7 @@ FixMyStreet::override_config {
subtest 'test crew reported issue' => sub {
set_fixed_time('2020-05-21T12:00:00Z'); # After sample container mix
$mech->get_ok('/waste/uprn/12345');
+ $mech->content_like(qr/Mixed Recycling.*?Last collection<\/dt>\s*<dd[^>]*>\s*Wednesday, 20th May\s+\(this collection has been adjusted/s);
$mech->content_contains('A missed collection cannot be reported, please see the last collection status above.');
$mech->content_lacks('Report a mixed recycling ');
restore_time();
diff --git a/templates/web/base/waste/bin_days.html b/templates/web/base/waste/bin_days.html
index da55c57fb..9ca8c0a7f 100644
--- a/templates/web/base/waste/bin_days.html
+++ b/templates/web/base/waste/bin_days.html
@@ -47,19 +47,18 @@
[% END %]
</dd>
</div>
+ [% IF unit.last %]
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Last collection</dt>
<dd class="govuk-summary-list__value">
- [% IF unit.last %]
[% date.format(unit.last.date) | replace('~~~', unit.last.ordinal) %]
+ [% IF unit.last.changed %](this collection has been adjusted from its usual time)[% END %]
[% IF unit.last.state == 'In progress' %](in progress)[% END %]
[% IF unit.last.completed %](completed at [% date.format(unit.last.completed, '%l:%M%p') | lower ~%])[% END ~%]
[% IF unit.last.resolution %][% unit.last.resolution | staff_html_markup({ is_body_user => 1 }) %][% END ~%]
- [% ELSE %]
- <i>None</i>
- [% END %]
</dd>
</div>
+ [% END %]
</dl>
<p class="waste-panel-toggle hidden-nojs"><a data-toggle-visibility="#panel-[% unit.service_id %]" class="waste-service-name-link govuk-button govuk-button--secondary">[% unit.service_name %] services</a></p>