Skip to content

Commit 853fc43

Browse files
committed
Updated /api/get_execution_status for running job
1 parent a0359ac commit 853fc43

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/server/api/admin_api.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,27 +149,25 @@ def list_statistics():
149149
return last_execution_details
150150

151151

152-
@admin_api.route("/api/get_execution_status/<int:job_id>", methods=["GET"])
152+
@admin_api.route("/api/get_execution_status", methods=["GET"])
153153
@jwt_ops.admin_required
154-
def get_exec_status(job_id):
155-
""" Get the execution status record from the DB for the specified job_id """
154+
def get_exec_status():
155+
""" Get the execution status record from the DB for a running job, if present"""
156156

157157

158158
engine.dispose() # we don't want other process's conn pool
159159

160160
with engine.connect() as connection:
161+
q = text("""SELECT job_id, stage, status, details, update_stamp
162+
FROM execution_status
163+
WHERE status = 'executing' """)
164+
result = connection.execute(q)
161165

162-
s_jobid = 'job-' + str(job_id)
163-
s = text("select valcol from kv_unique where keycol = :j ;")
164-
s = s.bindparams(j=s_jobid)
165-
result = connection.execute(s)
166166
if result.rowcount > 0:
167-
exec_status = result.fetchone()[0]
167+
running_job = result.fetchone()
168+
return jsonify(dict(zip(result.keys(), running_job)))
168169
else:
169-
current_app.logger.warning("0 results for exec status query")
170-
exec_status = '{}'
171-
172-
return exec_status
170+
return jsonify('')
173171

174172
@admin_api.route("/api/job_in_progress", methods=["GET"])
175173
@jwt_ops.admin_required

0 commit comments

Comments
 (0)