Skip to content

Commit

Permalink
[Abavus] Make sure generated end date is within scope.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Feb 6, 2024
1 parent adca3e2 commit 63c08bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions perllib/Open311/Endpoint/Integration/Abavus.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion t/open311/endpoint/abavus.t
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
];

Expand Down

0 comments on commit 63c08bf

Please sign in to comment.