[fix] in case the db is totally empty, index is buggy

This commit is contained in:
Laurent Peuch 2020-12-30 00:58:49 +01:00
parent a80501208b
commit 8b89935eb3

8
run.py
View file

@ -580,9 +580,15 @@ async def ws_index(request, websocket):
map(model_to_dict, Job.select().where(Job.state == "running").iterator()),
map(model_to_dict, latest_done_jobs.iterator())), 30)
try:
first_chunck = next(data)
except StopIteration:
# in case data is empty
first_chunck = []
await websocket.send(ujson.dumps({
"action": "init_jobs",
"data": next(data), # send first chunk
"data": first_chunck, # send first chunk
}))
for chunk in data: