From 220774afd921fae9b097db911d66f094edbe9010 Mon Sep 17 00:00:00 2001 From: Jan Bernitt Date: Thu, 26 Oct 2023 14:08:48 +0200 Subject: [PATCH] fix: only exclude actual 'run once' jobs from scheduler main list [DHIS2-16074] (#15494) --- .../main/java/org/hisp/dhis/scheduling/JobConfiguration.java | 5 ++++- .../dhis/webapi/controller/JobSchedulerControllerTest.java | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobConfiguration.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobConfiguration.java index 842c0b13a2f0..7eca33034291 100644 --- a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobConfiguration.java +++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/JobConfiguration.java @@ -341,7 +341,10 @@ public boolean isUsedInQueue() { } public boolean isRunOnce() { - return cronExpression == null && delay == null && queueName == null; + return schedulingType == SchedulingType.ONCE_ASAP + && cronExpression == null + && delay == null + && queueName == null; } public boolean isDueBetween( diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/JobSchedulerControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/JobSchedulerControllerTest.java index 047e63de8dee..959825d015c5 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/JobSchedulerControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/JobSchedulerControllerTest.java @@ -307,6 +307,9 @@ void testDeleteQueue() { assertStatus(HttpStatus.NO_CONTENT, DELETE("/scheduler/queues/testQueue")); assertStatus(HttpStatus.NOT_FOUND, GET("/scheduler/queues/testQueue")); + // verify the ex-queue jobs show in the scheduler main list again + JsonArray list = GET("/scheduler").content(); + assertEquals(3, list.size()); } @Test