#task_histories

This commit is contained in:
xieshen 2020-11-03 16:33:09 +08:00
parent 2ba900cb02
commit a34971dfe0
1 changed files with 13 additions and 12 deletions

View File

@ -77,27 +77,28 @@ def task_histories(request):
histories = []
task_id = []
res = []
row1 = None
with connection.cursor() as cursor:
cursor.execute("select * from task_histories order by run_time desc limit 20;")
row = cursor.fetchall()
res = []
task = []
for r in row:
o = dict()
print(r)
histories.append(r)
task_id.append(r[1])
o = dict()
o['status'] = r[2]
o['run_time'] = r[3]
o['output'] = r[4][1:-1]
task.append(o)
with connection.cursor() as cursor1:
cursor1.execute("select * from tasks where id = '%s'" % (r[1]))
row1 = cursor1.fetchall()
for r1 in row1:
o['task_name'] = r1[1]
o['task_type'] = r1[2]
o['desc'] = r1[8]
res.append(o)
cursor1.execute("select * from tasks where id = '%s' limit 1" % (r[1]))
row1 = cursor1.fetchone()
task.append(row1[1])
task.append(row1[2])
task.append(row1[8])
res.append(task)
return HttpResponse(json.dumps({
"status":"1",
"res":res