#task_histories
This commit is contained in:
parent
ac24f67587
commit
6a78f11381
|
@ -5,4 +5,5 @@ from dashboard import views
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('monotoring/',views.monotoring),
|
path('monotoring/',views.monotoring),
|
||||||
path('alarm/',views.alarm),
|
path('alarm/',views.alarm),
|
||||||
|
path('task/histories/',views.task_histories),
|
||||||
]
|
]
|
|
@ -73,3 +73,33 @@ def alarm(request):
|
||||||
"name": name,
|
"name": name,
|
||||||
"res":res
|
"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
|
||||||
|
}))
|
Loading…
Reference in New Issue