From cecfbd378abdc39c38956fe23b5120c5eb2535c3 Mon Sep 17 00:00:00 2001 From: Will Gunter Date: Thu, 25 Apr 2024 13:03:56 -0400 Subject: [PATCH] Update SQL command to get more accurate count of running processes --- .../main/java/jpl/cws/core/db/SchedulerDbService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java b/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java index 7dd9c353..98db043f 100644 --- a/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java +++ b/cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java @@ -400,8 +400,8 @@ public int getCountForClaimedProcInstPerKey(String procDefKey, List clai public List> getProcDefKeyLatestCompleteInst(String procDefKey) { return jdbcTemplate.queryForList( - "SELECT proc_inst_id, start_time, end_time FROM cws_proc_inst_status WHERE proc_def_key=? AND status='complete' ORDER BY start_time DESC LIMIT 1", - new Object[]{procDefKey} + "SELECT proc_inst_id, start_time, end_time FROM cws_proc_inst_status WHERE proc_def_key=? AND status='complete' ORDER BY start_time DESC LIMIT 1", + new Object[]{procDefKey} ); } @@ -604,8 +604,10 @@ public int getNumUpWorkers() { */ public List> getWorkerNumRunningProcs() { return jdbcTemplate.queryForList( - "SELECT cws_worker.id, active_count as cnt " + - "FROM cws_worker"); + "SELECT cws_worker.id, COUNT(*) AS cnt FROM cws_proc_inst_status," + + "cws_worker,cws_sched_worker_proc_inst WHERE cws_worker.id = cws_sched_worker_proc_inst.claimed_by_worker" + + " AND cws_sched_worker_proc_inst.proc_inst_id = cws_proc_inst_status.proc_inst_id AND " + + "cws_proc_inst_status.status NOT LIKE '%complete%' GROUP BY cws_worker.id"); }