From 63c08bfcf16e79f088dc2001d7f5e0bcf1e7ba82 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 24 Aug 2023 11:54:53 +0100 Subject: [PATCH] [Abavus] Make sure generated end date is within scope. --- perllib/Open311/Endpoint/Integration/Abavus.pm | 11 +++++++++++ t/open311/endpoint/abavus.t | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/perllib/Open311/Endpoint/Integration/Abavus.pm b/perllib/Open311/Endpoint/Integration/Abavus.pm index 28be09102..838216b98 100644 --- a/perllib/Open311/Endpoint/Integration/Abavus.pm +++ b/perllib/Open311/Endpoint/Integration/Abavus.pm @@ -361,6 +361,16 @@ sub post_service_request_update { sub get_service_request_updates { my ($self, $args) = @_; + # given we don't have an update time set a default of 20 seconds in the + # past of the end date. The -20 seconds is because FMS checks that comments + # aren't in the future WRT when it made the request so the -20 gets round + # that. + my $update_time = DateTime->now->add( seconds => -20 ); + if ($args->{end_date}) { + my $w3c = DateTime::Format::W3CDTF->new; + my $update_time = $w3c->parse_datetime($args->{end_date}); + } + my $fetched_updates = $self->abavus->api_call(call => 'serviceRequest/event/status'); if ($fetched_updates->{message} eq 'No Events Found') { return (); @@ -379,6 +389,7 @@ sub get_service_request_updates { description => '', update_id => $update->{ServiceEvent}->{guid}, service_request_id => $update->{ServiceEvent}->{number}, + updated_datetime => $update_time, ); push @updates, Open311::Endpoint::Service::Request::Update::mySociety->new( %update_args ); } else { diff --git a/t/open311/endpoint/abavus.t b/t/open311/endpoint/abavus.t index 5337a77e9..5865ced76 100644 --- a/t/open311/endpoint/abavus.t +++ b/t/open311/endpoint/abavus.t @@ -211,7 +211,7 @@ subtest 'check fetch updates' => sub { 'status' => 'investigating', 'description' => '', 'media_url' => '', - 'updated_datetime' => '2023-05-01T12:00:00Z', + 'updated_datetime' => '2023-05-01T11:59:40Z', } ];