diff --git a/lib/Thruk/Controller/Rest/V1/outages.pm b/lib/Thruk/Controller/Rest/V1/outages.pm index 06f0e2f9c..4a2df6bc2 100644 --- a/lib/Thruk/Controller/Rest/V1/outages.pm +++ b/lib/Thruk/Controller/Rest/V1/outages.pm @@ -426,6 +426,10 @@ sub _rest_query_time_filter { } } + if($c->req->parameters->{'start'} && !$c->req->parameters->{'end'}) { + $c->req->parameters->{'end'} = time(); + } + # combine remaining filter again $c->req->parameters->{'q'} = Thruk::Utils::Status::filter2text($c, undef, $filter); @@ -487,7 +491,11 @@ sub _rest_replace_logs_time_filter { if($start) { $c->req->parameters->{'start'} = $start; - $c->req->parameters->{'end'} = $end // time(); + } + if($end) { + $c->req->parameters->{'end'} = $end; + } + if($start || $end) { return 1; } } diff --git a/lib/Thruk/Controller/rest_v1.pm b/lib/Thruk/Controller/rest_v1.pm index 0ba9d59a1..52e562019 100644 --- a/lib/Thruk/Controller/rest_v1.pm +++ b/lib/Thruk/Controller/rest_v1.pm @@ -2632,7 +2632,7 @@ sub _match_complex_filter { for my $op (%{$val}) { my $localkey = $key; if(!defined $data->{$localkey}) { - # translate some keys back + # translate some keys back (set from Utils::Status::parse_lexical_filter) if($localkey eq 'host_name' && defined $data->{'host'}) { $localkey = 'host'; } elsif($localkey eq 'description' && defined $data->{'service'}) { diff --git a/t/scenarios/rest_api/t/301-controller_rest_scenario.t b/t/scenarios/rest_api/t/301-controller_rest_scenario.t index 8ca94317f..95eb5fe02 100644 --- a/t/scenarios/rest_api/t/301-controller_rest_scenario.t +++ b/t/scenarios/rest_api/t/301-controller_rest_scenario.t @@ -6,7 +6,7 @@ use Test::More; die("*** ERROR: this test is meant to be run with PLACK_TEST_EXTERNALSERVER_URI set,\nex.: THRUK_TEST_AUTH=omdadmin:omd PLACK_TEST_EXTERNALSERVER_URI=http://localhost:60080/demo perl t/scenarios/rest_api/t/301-controller_rest_scenario.t") unless defined $ENV{'PLACK_TEST_EXTERNALSERVER_URI'}; BEGIN { - plan tests => 370; + plan tests => 378; use lib('t'); require TestUtils; @@ -66,6 +66,9 @@ my $pages = [{ }, { url => '/logs?q=***type = "EXTERNAL COMMAND" and time > '.(time() - 600).'***', like => ['EXTERNAL COMMAND'], + }, { + url => '/services/outages?q=***host = "localhost" and service = "Ping" and timeperiod = "today"***', + like => ['\[\]'], }, { url => '/services/localhost/Ping/config', method => 'PATCH',