mirror of
https://github.com/simon987/od-database.git
synced 2025-12-13 14:59:02 +00:00
Added redispatch button and fixed typo in load balancing code
This commit is contained in:
@@ -83,6 +83,16 @@ class TaskManagerDatabase:
|
||||
else:
|
||||
return None
|
||||
|
||||
def pop_all_tasks(self):
|
||||
|
||||
tasks = self.get_tasks()
|
||||
|
||||
with sqlite3.connect(self.db_path) as conn:
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("DELETE FROM Queue")
|
||||
return tasks
|
||||
|
||||
def put_task(self, task: Task):
|
||||
|
||||
with sqlite3.connect(self.db_path) as conn:
|
||||
|
||||
@@ -90,6 +90,14 @@ def get_task_logs():
|
||||
return Response(json_str, mimetype="application/json")
|
||||
|
||||
|
||||
@app.route("/task/pop_all")
|
||||
@auth.login_required
|
||||
def pop_queued_tasks():
|
||||
|
||||
json_str = json.dumps([task.to_json() for task in tm.pop_tasks()])
|
||||
return Response(json_str, mimetype="application/json")
|
||||
|
||||
|
||||
@app.route("/stats/")
|
||||
@auth.login_required
|
||||
def get_stats():
|
||||
|
||||
@@ -27,6 +27,9 @@ class TaskManager:
|
||||
def get_tasks(self):
|
||||
return self.db.get_tasks()
|
||||
|
||||
def pop_tasks(self):
|
||||
return self.db.pop_all_tasks()
|
||||
|
||||
def get_current_tasks(self):
|
||||
return self.current_tasks
|
||||
|
||||
|
||||
Reference in New Issue
Block a user