Skip to content

Commit

Permalink
Update SQL command to get more accurate count of running processes
Browse files Browse the repository at this point in the history
  • Loading branch information
wcgunter committed Apr 25, 2024
1 parent 2f41156 commit cecfbd3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cws-core/src/main/java/jpl/cws/core/db/SchedulerDbService.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ public int getCountForClaimedProcInstPerKey(String procDefKey, List<String> clai

public List<Map<String, Object>> 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}
);
}

Expand Down Expand Up @@ -604,8 +604,10 @@ public int getNumUpWorkers() {
*/
public List<Map<String, Object>> 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");
}


Expand Down

0 comments on commit cecfbd3

Please sign in to comment.