Skip to content

Commit

Permalink
Return timestamps with offset to client for needle info
Browse files Browse the repository at this point in the history
  • Loading branch information
perlpunk committed Sep 30, 2024
1 parent 7105152 commit 32c27f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lib/OpenQA/Schema/Result/Needles.pm
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,12 @@ sub to_json ($self) {
};
}

my $fmt = '%Y-%m-%dT%H:%M:%S%z'; # with offset
sub last_seen_time_fmt ($self) {
$self->last_seen_time ? $self->last_seen_time->strftime($fmt) : 'never';
}
sub last_matched_time_fmt ($self) {
$self->last_matched_time ? $self->last_matched_time->strftime($fmt) : 'never';
}

1;
4 changes: 2 additions & 2 deletions lib/OpenQA/WebAPI/Plugin/Helpers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ sub register ($self, $app, $config) {
populate_hash_with_needle_timestamps_and_urls => sub {
my ($c, $needle, $hash) = @_;

$hash->{last_seen} = $needle ? $needle->last_seen_time || 'never' : 'unknown';
$hash->{last_match} = $needle ? $needle->last_matched_time || 'never' : 'unknown';
$hash->{last_seen} = $needle ? $needle->last_seen_time_fmt : 'unknown';
$hash->{last_match} = $needle ? $needle->last_matched_time_fmt : 'unknown';
return $hash unless $needle;
if (my $last_seen_module_id = $needle->last_seen_module_id) {
$hash->{last_seen_link} = $c->url_for(
Expand Down

0 comments on commit 32c27f9

Please sign in to comment.