Skip to content

Commit 980b1a0

Browse files
committed
[Abavus] Make sure generated end date is within scope.
1 parent 4c1bffe commit 980b1a0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

perllib/Open311/Endpoint/Integration/Abavus.pm

+11
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,16 @@ sub post_service_request_update {
361361
sub get_service_request_updates {
362362
my ($self, $args) = @_;
363363

364+
# given we don't have an update time set a default of 20 seconds in the
365+
# past of the end date. The -20 seconds is because FMS checks that comments
366+
# aren't in the future WRT when it made the request so the -20 gets round
367+
# that.
368+
my $update_time = DateTime->now->add( seconds => -20 );
369+
if ($args->{end_date}) {
370+
my $w3c = DateTime::Format::W3CDTF->new;
371+
my $update_time = $w3c->parse_datetime($args->{end_date});
372+
}
373+
364374
my $fetched_updates = $self->abavus->api_call(call => 'serviceRequest/event/status');
365375
if ($fetched_updates->{message} eq 'No Events Found') {
366376
return ();
@@ -379,6 +389,7 @@ sub get_service_request_updates {
379389
description => '',
380390
update_id => $update->{ServiceEvent}->{guid},
381391
service_request_id => $update->{ServiceEvent}->{number},
392+
updated_datetime => $update_time,
382393
);
383394
push @updates, Open311::Endpoint::Service::Request::Update::mySociety->new( %update_args );
384395
} else {

t/open311/endpoint/abavus.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ subtest 'check fetch updates' => sub {
211211
'status' => 'investigating',
212212
'description' => '',
213213
'media_url' => '',
214-
'updated_datetime' => '2023-05-01T12:00:00Z',
214+
'updated_datetime' => '2023-05-01T11:59:40Z',
215215
}
216216
];
217217

0 commit comments

Comments
 (0)