style: auto-format code with ruff (cron)
This commit is contained in:
@@ -500,7 +500,7 @@ class CacheManager:
|
||||
WHERE e.project_id = ?
|
||||
ORDER BY mention_count DESC
|
||||
LIMIT 100""",
|
||||
(project_id, ),
|
||||
(project_id,),
|
||||
).fetchall()
|
||||
|
||||
for entity in entities:
|
||||
@@ -517,7 +517,7 @@ class CacheManager:
|
||||
JOIN entities e2 ON r.target_entity_id = e2.id
|
||||
WHERE r.project_id = ?
|
||||
LIMIT 200""",
|
||||
(project_id, ),
|
||||
(project_id,),
|
||||
).fetchall()
|
||||
|
||||
for relation in relations:
|
||||
@@ -531,7 +531,7 @@ class CacheManager:
|
||||
WHERE project_id = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 10""",
|
||||
(project_id, ),
|
||||
(project_id,),
|
||||
).fetchall()
|
||||
|
||||
for transcript in transcripts:
|
||||
@@ -548,11 +548,11 @@ class CacheManager:
|
||||
|
||||
# 预热项目知识库摘要
|
||||
entity_count = conn.execute(
|
||||
"SELECT COUNT(*) FROM entities WHERE project_id = ?", (project_id, )
|
||||
"SELECT COUNT(*) FROM entities WHERE project_id = ?", (project_id,)
|
||||
).fetchone()[0]
|
||||
|
||||
relation_count = conn.execute(
|
||||
"SELECT COUNT(*) FROM entity_relations WHERE project_id = ?", (project_id, )
|
||||
"SELECT COUNT(*) FROM entity_relations WHERE project_id = ?", (project_id,)
|
||||
).fetchone()[0]
|
||||
|
||||
summary = {
|
||||
@@ -757,11 +757,11 @@ class DatabaseSharding:
|
||||
source_conn.row_factory = sqlite3.Row
|
||||
|
||||
entities = source_conn.execute(
|
||||
"SELECT * FROM entities WHERE project_id = ?", (project_id, )
|
||||
"SELECT * FROM entities WHERE project_id = ?", (project_id,)
|
||||
).fetchall()
|
||||
|
||||
relations = source_conn.execute(
|
||||
"SELECT * FROM entity_relations WHERE project_id = ?", (project_id, )
|
||||
"SELECT * FROM entity_relations WHERE project_id = ?", (project_id,)
|
||||
).fetchall()
|
||||
|
||||
source_conn.close()
|
||||
@@ -794,8 +794,8 @@ class DatabaseSharding:
|
||||
|
||||
# 从源分片删除数据
|
||||
source_conn = sqlite3.connect(source_info.db_path)
|
||||
source_conn.execute("DELETE FROM entities WHERE project_id = ?", (project_id, ))
|
||||
source_conn.execute("DELETE FROM entity_relations WHERE project_id = ?", (project_id, ))
|
||||
source_conn.execute("DELETE FROM entities WHERE project_id = ?", (project_id,))
|
||||
source_conn.execute("DELETE FROM entity_relations WHERE project_id = ?", (project_id,))
|
||||
source_conn.commit()
|
||||
source_conn.close()
|
||||
|
||||
@@ -1024,7 +1024,7 @@ class TaskQueue:
|
||||
with self.task_lock:
|
||||
self.tasks[task_id] = task
|
||||
# 异步执行
|
||||
threading.Thread(target=self._execute_task, args=(task_id, ), daemon=True).start()
|
||||
threading.Thread(target=self._execute_task, args=(task_id,), daemon=True).start()
|
||||
|
||||
# 保存到数据库
|
||||
self._save_task(task)
|
||||
@@ -1061,7 +1061,7 @@ class TaskQueue:
|
||||
task.status = "retrying"
|
||||
# 延迟重试
|
||||
threading.Timer(
|
||||
10 * task.retry_count, self._execute_task, args=(task_id, )
|
||||
10 * task.retry_count, self._execute_task, args=(task_id,)
|
||||
).start()
|
||||
else:
|
||||
task.status = "failed"
|
||||
@@ -1248,7 +1248,7 @@ class TaskQueue:
|
||||
if not self.use_celery:
|
||||
with self.task_lock:
|
||||
self.tasks[task_id] = task
|
||||
threading.Thread(target=self._execute_task, args=(task_id, ), daemon=True).start()
|
||||
threading.Thread(target=self._execute_task, args=(task_id,), daemon=True).start()
|
||||
|
||||
self._update_task_status(task)
|
||||
return True
|
||||
@@ -1439,7 +1439,7 @@ class PerformanceMonitor:
|
||||
FROM performance_metrics
|
||||
WHERE timestamp > datetime('now', ?)
|
||||
""",
|
||||
(f"-{hours} hours", ),
|
||||
(f"-{hours} hours",),
|
||||
).fetchone()
|
||||
|
||||
# 按类型统计
|
||||
@@ -1454,7 +1454,7 @@ class PerformanceMonitor:
|
||||
WHERE timestamp > datetime('now', ?)
|
||||
GROUP BY metric_type
|
||||
""",
|
||||
(f"-{hours} hours", ),
|
||||
(f"-{hours} hours",),
|
||||
).fetchall()
|
||||
|
||||
# 按端点统计(API)
|
||||
@@ -1472,7 +1472,7 @@ class PerformanceMonitor:
|
||||
ORDER BY avg_duration DESC
|
||||
LIMIT 20
|
||||
""",
|
||||
(f"-{hours} hours", ),
|
||||
(f"-{hours} hours",),
|
||||
).fetchall()
|
||||
|
||||
# 慢查询统计
|
||||
@@ -1597,7 +1597,7 @@ class PerformanceMonitor:
|
||||
DELETE FROM performance_metrics
|
||||
WHERE timestamp < datetime('now', ?)
|
||||
""",
|
||||
(f"-{days} days", ),
|
||||
(f"-{days} days",),
|
||||
)
|
||||
|
||||
deleted = cursor.rowcount
|
||||
|
||||
Reference in New Issue
Block a user