Skip to content
Snippets Groups Projects
Commit 8a3f12bc authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Use new database structure in serve_overview

parent 0f67b362
No related branches found
No related tags found
1 merge request!683[Webservice] Restructure database to give more meaningful success/failure information
......@@ -269,19 +269,19 @@ class RequestHandler(BaseHTTPRequestHandler):
last_correction_r = Template(tmpl).render(info=last_calib, host=host,
port=port)
conn = sqlite3.connect(config['web-service']['job-db']).cursor()
conn.execute("SELECT * FROM jobs WHERE status IN ('R', 'PD', 'CG')")
conn = sqlite3.connect(config['web-service']['job-db'])
c = conn.execute(
"SELECT status, elapsed, det_type, proposal, run, action FROM "
"slurm_jobs INNER JOIN executions USING (exec_id) "
"INNER JOIN requests USING (req_id) "
"WHERE finished = 0"
)
running_jobs = {}
for r in conn.fetchall():
rid, jobid, proposal, run, status, time, det, act = r
run = int(run)
key = '{}/r{:04d}/{}/{}'.format(proposal, run, det, act)
flg = "R"
if status in ["QUEUE", "PD"]:
flg = "Q"
rjobs = running_jobs.get(key, [])
rjobs.append((flg, '{}-{}'.format(status, time)))
running_jobs[key] = rjobs
for status, elapsed, det, proposal, run, act in c:
key = f'{proposal}/r{int(run):04d}/{det}/{act}'
flg = "Q" if status in {"QUEUE", "PD"} else "R"
rjobs = running_jobs.setdefault(key, [])
rjobs.append((flg, f'{status}-{elapsed}'))
tmpl = self.templates["running-jobs"]
running_jobs_r = Template(tmpl).render(running_jobs=running_jobs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment