fix: auto-fix code issues (cron)

- 修复重复导入/字段
- 修复异常处理
- 修复PEP8格式问题 (816+ 处)
- 添加缺失的导入 (json, re)
- 统一SQL查询格式
- 修复赋值语句空格问题

修复文件:
- db_manager.py (96处)
- search_manager.py (77处)
- ops_manager.py (66处)
- developer_ecosystem_manager.py (68处)
- growth_manager.py (60处)
- enterprise_manager.py (61处)
- tenant_manager.py (57处)
- plugin_manager.py (48处)
- subscription_manager.py (46处)
- security_manager.py (29处)
- workflow_manager.py (32处)
- localization_manager.py (31处)
- api_key_manager.py (20处)
- ai_manager.py (23处)
- performance_manager.py (24处)
- neo4j_manager.py (25处)
- collaboration_manager.py (33处)
- test_phase8_task8.py (16处)
- test_phase8_task6.py (4处)
- knowledge_reasoner.py (添加import json)
- llm_client.py (添加import json)
This commit is contained in:
AutoFix Bot
2026-03-03 00:11:51 +08:00
parent c695e99eaf
commit 2a0ed6af4d
23 changed files with 1160 additions and 947 deletions

View File

@@ -495,9 +495,9 @@ class CacheManager:
# 预热实体数据
entities = conn.execute(
"""SELECT e.*,
(SELECT COUNT(*) FROM entity_mentions m WHERE m.entity_id = e.id) as mention_count
(SELECT COUNT(*) FROM entity_mentions m WHERE m.entity_id = e.id) as mention_count
FROM entities e
WHERE e.project_id = ?
WHERE e.project_id = ?
ORDER BY mention_count DESC
LIMIT 100""",
(project_id,),
@@ -513,9 +513,9 @@ class CacheManager:
"""SELECT r.*,
e1.name as source_name, e2.name as target_name
FROM entity_relations r
JOIN entities e1 ON r.source_entity_id = e1.id
JOIN entities e2 ON r.target_entity_id = e2.id
WHERE r.project_id = ?
JOIN entities e1 ON r.source_entity_id = e1.id
JOIN entities e2 ON r.target_entity_id = e2.id
WHERE r.project_id = ?
LIMIT 200""",
(project_id,),
).fetchall()
@@ -528,7 +528,7 @@ class CacheManager:
# 预热最近的转录
transcripts = conn.execute(
"""SELECT * FROM transcripts
WHERE project_id = ?
WHERE project_id = ?
ORDER BY created_at DESC
LIMIT 10""",
(project_id,),
@@ -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()
@@ -1110,13 +1110,13 @@ class TaskQueue:
conn.execute(
"""
UPDATE task_queue SET
status = ?,
result = ?,
error_message = ?,
retry_count = ?,
started_at = ?,
completed_at = ?
WHERE id = ?
status = ?,
result = ?,
error_message = ?,
retry_count = ?,
started_at = ?,
completed_at = ?
WHERE id = ?
""",
(
task.status,
@@ -1173,11 +1173,11 @@ class TaskQueue:
params = []
if status:
where_clauses.append("status = ?")
where_clauses.append("status = ?")
params.append(status)
if task_type:
where_clauses.append("task_type = ?")
where_clauses.append("task_type = ?")
params.append(task_type)
where_str = " AND ".join(where_clauses) if where_clauses else "1 = 1"
@@ -1467,7 +1467,7 @@ class PerformanceMonitor:
MAX(duration_ms) as max_duration
FROM performance_metrics
WHERE timestamp > datetime('now', ?)
AND metric_type = 'api_response'
AND metric_type = 'api_response'
GROUP BY endpoint
ORDER BY avg_duration DESC
LIMIT 20
@@ -1538,11 +1538,11 @@ class PerformanceMonitor:
conn = sqlite3.connect(self.db_path)
conn.row_factory = sqlite3.Row
where_clause = "metric_type = 'api_response'"
where_clause = "metric_type = 'api_response'"
params = [f"-{hours} hours"]
if endpoint:
where_clause += " AND endpoint = ?"
where_clause += " AND endpoint = ?"
params.append(endpoint)
# 百分位数统计