移除配置

This commit is contained in:
2024-11-04 05:58:03 +08:00
parent 847bb0f430
commit ee88acf9a8
4 changed files with 18 additions and 128 deletions

View File

@@ -5,8 +5,6 @@ from pydantic import BaseModel
from configs.config import SQLITE3_PATH
import uuid
import time
import requests
__taskdb = sqlite3.connect(os.path.join(SQLITE3_PATH, 'tasks.db'), check_same_thread=False)
__taskdb.row_factory = sqlite3.Row
@@ -104,81 +102,4 @@ class TaskManager:
break
print(f"get task status:{task.id}")
break
#data = requests.get(f"http://localhost:5001/api/task/{task.id}").json()
#print(data)
## 通过 http 请求获取任务的状态
## 如果任务状态发生变化, 则将任务状态发送给所有监听该任务的 websocket
#if task.status != data.status:
# task.status = data.status
# print("send task status to websocket")
# for websocket in task.websockets:
# await websocket.send_json(task)
## 任务实体模型
#class TaskModel(BaseModel):
# id: str
# name: str
# user_id: int
# description: str
# created_at: str
# updated_at: str
# websockets: list=[]
#
## 向数据库中添加任务
#def add_task(name, user_id, description):
# print(name, user_id, description)
# date = datetime.datetime.now()
# cursor = __taskdb.cursor()
# cursor.execute("INSERT INTO tasks(name,user_id,description,created_at,updated_at) VALUES (?, ?, ?, ?, ?)", (name,user_id,description,date,date))
# id = cursor.lastrowid
# cursor.close()
# __taskdb.commit()
# return {"id": id,"name": name,"user_id": user_id,"description": description,"created_at": date,"updated_at": date}
#
#
## 从数据库中获取任务列表
#def get_tasks(user_id: int=None):
# cursor = __taskdb.cursor()
# if user_id:
# cursor.execute("SELECT * FROM tasks WHERE user_id = ?", (user_id,))
# else:
# cursor.execute("SELECT * FROM tasks")
# tasks = cursor.fetchall()
# cursor.close()
# return [dict(task) for task in tasks]
#
#
## 从数据库中获取指定任务
#def get_task(task_id: int):
# cursor = __taskdb.cursor()
# cursor.execute("SELECT * FROM tasks WHERE id = ?", (task_id,))
# task = cursor.fetchone()
# cursor.close()
# return task
#
#
## 更新数据库中的任务
#def update_task(task: TaskModel):
# cursor = __taskdb.cursor()
# cursor.execute("UPDATE tasks SET name = ?, description = ?, updated_at = ? WHERE id = ?", (
# task.name,
# task.description,
# datetime.datetime.now(),
# task.id
# ))
# cursor.close()
# __taskdb.commit()
# return task
#
#
## 从数据库中删除任务
#def delete_task(task_id: int):
# cursor = __taskdb.cursor()
# cursor.execute("DELETE FROM tasks WHERE id = ?", (task_id,))
# cursor.close()
# __taskdb.commit()
# return task_id