#task_histories

This commit is contained in:
xieshen 2020-11-03 10:10:34 +08:00
parent ac24f67587
commit 6a78f11381
2 changed files with 31 additions and 0 deletions

View File

@ -5,4 +5,5 @@ from dashboard import views
urlpatterns = [
path('monotoring/',views.monotoring),
path('alarm/',views.alarm),
path('task/histories/',views.task_histories),
]

View File

@ -73,3 +73,33 @@ def alarm(request):
"name": name,
"res":res
}))
def task_histories(request):
histories = []
task_id = []
with connection.cursor() as cursor:
cursor.execute("select * from task_histories order by run_time desc limit 20;")
row = cursor.fetchall()
res = []
for r in row:
o = dict()
print(r)
histories.append(r)
task_id.append(r[1])
o['status'] = r[2]
o['run_time'] = r[3]
o['output'] = r[4]
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)
return HttpResponse(json.dumps({
"status":"1",
"res":res
}))