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:
@@ -152,7 +152,7 @@ class TemplateMarketItem:
|
||||
author_id: str
|
||||
author_name: str
|
||||
status: TemplateStatus
|
||||
price: float # 0 = 免费
|
||||
price: float # 0 = 免费
|
||||
currency: str
|
||||
preview_image_url: str | None
|
||||
demo_url: str | None
|
||||
@@ -444,7 +444,7 @@ class DeveloperEcosystemManager:
|
||||
def get_sdk_release(self, sdk_id: str) -> SDKRelease | None:
|
||||
"""获取 SDK 发布详情"""
|
||||
with self._get_db() as conn:
|
||||
row = conn.execute("SELECT * FROM sdk_releases WHERE id = ?", (sdk_id,)).fetchone()
|
||||
row = conn.execute("SELECT * FROM sdk_releases WHERE id = ?", (sdk_id,)).fetchone()
|
||||
|
||||
if row:
|
||||
return self._row_to_sdk_release(row)
|
||||
@@ -461,10 +461,10 @@ class DeveloperEcosystemManager:
|
||||
params = []
|
||||
|
||||
if language:
|
||||
query += " AND language = ?"
|
||||
query += " AND language = ?"
|
||||
params.append(language.value)
|
||||
if status:
|
||||
query += " AND status = ?"
|
||||
query += " AND status = ?"
|
||||
params.append(status.value)
|
||||
if search:
|
||||
query += " AND (name LIKE ? OR description LIKE ? OR package_name LIKE ?)"
|
||||
@@ -497,7 +497,7 @@ class DeveloperEcosystemManager:
|
||||
with self._get_db() as conn:
|
||||
set_clause = ", ".join([f"{k} = ?" for k in updates.keys()])
|
||||
conn.execute(
|
||||
f"UPDATE sdk_releases SET {set_clause} WHERE id = ?",
|
||||
f"UPDATE sdk_releases SET {set_clause} WHERE id = ?",
|
||||
list(updates.values()) + [sdk_id],
|
||||
)
|
||||
conn.commit()
|
||||
@@ -512,8 +512,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE sdk_releases
|
||||
SET status = ?, published_at = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
SET status = ?, published_at = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(SDKStatus.STABLE.value, now, now, sdk_id),
|
||||
)
|
||||
@@ -527,8 +527,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE sdk_releases
|
||||
SET download_count = download_count + 1
|
||||
WHERE id = ?
|
||||
SET download_count = download_count + 1
|
||||
WHERE id = ?
|
||||
""",
|
||||
(sdk_id,),
|
||||
)
|
||||
@@ -538,7 +538,7 @@ class DeveloperEcosystemManager:
|
||||
"""获取 SDK 版本历史"""
|
||||
with self._get_db() as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT * FROM sdk_versions WHERE sdk_id = ? ORDER BY created_at DESC", (sdk_id,)
|
||||
"SELECT * FROM sdk_versions WHERE sdk_id = ? ORDER BY created_at DESC", (sdk_id,)
|
||||
).fetchall()
|
||||
return [self._row_to_sdk_version(row) for row in rows]
|
||||
|
||||
@@ -559,7 +559,7 @@ class DeveloperEcosystemManager:
|
||||
with self._get_db() as conn:
|
||||
# 如果设置为最新版本,取消其他版本的最新标记
|
||||
if True: # 默认新版本为最新
|
||||
conn.execute("UPDATE sdk_versions SET is_latest = 0 WHERE sdk_id = ?", (sdk_id,))
|
||||
conn.execute("UPDATE sdk_versions SET is_latest = 0 WHERE sdk_id = ?", (sdk_id,))
|
||||
|
||||
conn.execute(
|
||||
"""
|
||||
@@ -700,7 +700,7 @@ class DeveloperEcosystemManager:
|
||||
"""获取模板详情"""
|
||||
with self._get_db() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM template_market WHERE id = ?", (template_id,)
|
||||
"SELECT * FROM template_market WHERE id = ?", (template_id,)
|
||||
).fetchone()
|
||||
|
||||
if row:
|
||||
@@ -722,13 +722,13 @@ class DeveloperEcosystemManager:
|
||||
params = []
|
||||
|
||||
if category:
|
||||
query += " AND category = ?"
|
||||
query += " AND category = ?"
|
||||
params.append(category.value)
|
||||
if status:
|
||||
query += " AND status = ?"
|
||||
query += " AND status = ?"
|
||||
params.append(status.value)
|
||||
if author_id:
|
||||
query += " AND author_id = ?"
|
||||
query += " AND author_id = ?"
|
||||
params.append(author_id)
|
||||
if search:
|
||||
query += " AND (name LIKE ? OR description LIKE ? OR tags LIKE ?)"
|
||||
@@ -762,8 +762,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE template_market
|
||||
SET status = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
SET status = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(TemplateStatus.APPROVED.value, now, template_id),
|
||||
)
|
||||
@@ -779,8 +779,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE template_market
|
||||
SET status = ?, published_at = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
SET status = ?, published_at = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(TemplateStatus.PUBLISHED.value, now, now, template_id),
|
||||
)
|
||||
@@ -796,8 +796,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE template_market
|
||||
SET status = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
SET status = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(TemplateStatus.REJECTED.value, now, template_id),
|
||||
)
|
||||
@@ -811,8 +811,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE template_market
|
||||
SET install_count = install_count + 1
|
||||
WHERE id = ?
|
||||
SET install_count = install_count + 1
|
||||
WHERE id = ?
|
||||
""",
|
||||
(template_id,),
|
||||
)
|
||||
@@ -878,7 +878,7 @@ class DeveloperEcosystemManager:
|
||||
"""
|
||||
SELECT AVG(rating) as avg_rating, COUNT(*) as count
|
||||
FROM template_reviews
|
||||
WHERE template_id = ?
|
||||
WHERE template_id = ?
|
||||
""",
|
||||
(template_id,),
|
||||
).fetchone()
|
||||
@@ -887,8 +887,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE template_market
|
||||
SET rating = ?, rating_count = ?, review_count = ?
|
||||
WHERE id = ?
|
||||
SET rating = ?, rating_count = ?, review_count = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(
|
||||
round(row["avg_rating"], 2) if row["avg_rating"] else 0,
|
||||
@@ -903,7 +903,7 @@ class DeveloperEcosystemManager:
|
||||
with self._get_db() as conn:
|
||||
rows = conn.execute(
|
||||
"""SELECT * FROM template_reviews
|
||||
WHERE template_id = ?
|
||||
WHERE template_id = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT ?""",
|
||||
(template_id, limit),
|
||||
@@ -1032,7 +1032,7 @@ class DeveloperEcosystemManager:
|
||||
def get_plugin(self, plugin_id: str) -> PluginMarketItem | None:
|
||||
"""获取插件详情"""
|
||||
with self._get_db() as conn:
|
||||
row = conn.execute("SELECT * FROM plugin_market WHERE id = ?", (plugin_id,)).fetchone()
|
||||
row = conn.execute("SELECT * FROM plugin_market WHERE id = ?", (plugin_id,)).fetchone()
|
||||
|
||||
if row:
|
||||
return self._row_to_plugin(row)
|
||||
@@ -1051,13 +1051,13 @@ class DeveloperEcosystemManager:
|
||||
params = []
|
||||
|
||||
if category:
|
||||
query += " AND category = ?"
|
||||
query += " AND category = ?"
|
||||
params.append(category.value)
|
||||
if status:
|
||||
query += " AND status = ?"
|
||||
query += " AND status = ?"
|
||||
params.append(status.value)
|
||||
if author_id:
|
||||
query += " AND author_id = ?"
|
||||
query += " AND author_id = ?"
|
||||
params.append(author_id)
|
||||
if search:
|
||||
query += " AND (name LIKE ? OR description LIKE ? OR tags LIKE ?)"
|
||||
@@ -1085,8 +1085,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE plugin_market
|
||||
SET status = ?, reviewed_by = ?, reviewed_at = ?, review_notes = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
SET status = ?, reviewed_by = ?, reviewed_at = ?, review_notes = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(status.value, reviewed_by, now, notes, now, plugin_id),
|
||||
)
|
||||
@@ -1102,8 +1102,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE plugin_market
|
||||
SET status = ?, published_at = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
SET status = ?, published_at = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(PluginStatus.PUBLISHED.value, now, now, plugin_id),
|
||||
)
|
||||
@@ -1117,8 +1117,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE plugin_market
|
||||
SET install_count = install_count + 1
|
||||
WHERE id = ?
|
||||
SET install_count = install_count + 1
|
||||
WHERE id = ?
|
||||
""",
|
||||
(plugin_id,),
|
||||
)
|
||||
@@ -1127,8 +1127,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE plugin_market
|
||||
SET active_install_count = active_install_count + 1
|
||||
WHERE id = ?
|
||||
SET active_install_count = active_install_count + 1
|
||||
WHERE id = ?
|
||||
""",
|
||||
(plugin_id,),
|
||||
)
|
||||
@@ -1193,7 +1193,7 @@ class DeveloperEcosystemManager:
|
||||
"""
|
||||
SELECT AVG(rating) as avg_rating, COUNT(*) as count
|
||||
FROM plugin_reviews
|
||||
WHERE plugin_id = ?
|
||||
WHERE plugin_id = ?
|
||||
""",
|
||||
(plugin_id,),
|
||||
).fetchone()
|
||||
@@ -1202,8 +1202,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE plugin_market
|
||||
SET rating = ?, rating_count = ?, review_count = ?
|
||||
WHERE id = ?
|
||||
SET rating = ?, rating_count = ?, review_count = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(
|
||||
round(row["avg_rating"], 2) if row["avg_rating"] else 0,
|
||||
@@ -1218,7 +1218,7 @@ class DeveloperEcosystemManager:
|
||||
with self._get_db() as conn:
|
||||
rows = conn.execute(
|
||||
"""SELECT * FROM plugin_reviews
|
||||
WHERE plugin_id = ?
|
||||
WHERE plugin_id = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT ?""",
|
||||
(plugin_id, limit),
|
||||
@@ -1288,8 +1288,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE developer_profiles
|
||||
SET total_sales = total_sales + ?
|
||||
WHERE id = ?
|
||||
SET total_sales = total_sales + ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(sale_amount, developer_id),
|
||||
)
|
||||
@@ -1305,7 +1305,7 @@ class DeveloperEcosystemManager:
|
||||
end_date: datetime | None = None,
|
||||
) -> list[DeveloperRevenue]:
|
||||
"""获取开发者收益记录"""
|
||||
query = "SELECT * FROM developer_revenues WHERE developer_id = ?"
|
||||
query = "SELECT * FROM developer_revenues WHERE developer_id = ?"
|
||||
params = [developer_id]
|
||||
|
||||
if start_date:
|
||||
@@ -1332,7 +1332,7 @@ class DeveloperEcosystemManager:
|
||||
SUM(developer_earnings) as total_earnings,
|
||||
COUNT(*) as transaction_count
|
||||
FROM developer_revenues
|
||||
WHERE developer_id = ?
|
||||
WHERE developer_id = ?
|
||||
""",
|
||||
(developer_id,),
|
||||
).fetchone()
|
||||
@@ -1420,7 +1420,7 @@ class DeveloperEcosystemManager:
|
||||
"""获取开发者档案"""
|
||||
with self._get_db() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM developer_profiles WHERE id = ?", (developer_id,)
|
||||
"SELECT * FROM developer_profiles WHERE id = ?", (developer_id,)
|
||||
).fetchone()
|
||||
|
||||
if row:
|
||||
@@ -1431,7 +1431,7 @@ class DeveloperEcosystemManager:
|
||||
"""通过用户 ID 获取开发者档案"""
|
||||
with self._get_db() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM developer_profiles WHERE user_id = ?", (user_id,)
|
||||
"SELECT * FROM developer_profiles WHERE user_id = ?", (user_id,)
|
||||
).fetchone()
|
||||
|
||||
if row:
|
||||
@@ -1448,8 +1448,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE developer_profiles
|
||||
SET status = ?, verified_at = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
SET status = ?, verified_at = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(
|
||||
status.value,
|
||||
@@ -1469,12 +1469,12 @@ class DeveloperEcosystemManager:
|
||||
with self._get_db() as conn:
|
||||
# 统计插件数量
|
||||
plugin_row = conn.execute(
|
||||
"SELECT COUNT(*) as count FROM plugin_market WHERE author_id = ?", (developer_id,)
|
||||
"SELECT COUNT(*) as count FROM plugin_market WHERE author_id = ?", (developer_id,)
|
||||
).fetchone()
|
||||
|
||||
# 统计模板数量
|
||||
template_row = conn.execute(
|
||||
"SELECT COUNT(*) as count FROM template_market WHERE author_id = ?",
|
||||
"SELECT COUNT(*) as count FROM template_market WHERE author_id = ?",
|
||||
(developer_id,),
|
||||
).fetchone()
|
||||
|
||||
@@ -1482,9 +1482,9 @@ class DeveloperEcosystemManager:
|
||||
download_row = conn.execute(
|
||||
"""
|
||||
SELECT SUM(install_count) as total FROM (
|
||||
SELECT install_count FROM plugin_market WHERE author_id = ?
|
||||
SELECT install_count FROM plugin_market WHERE author_id = ?
|
||||
UNION ALL
|
||||
SELECT install_count FROM template_market WHERE author_id = ?
|
||||
SELECT install_count FROM template_market WHERE author_id = ?
|
||||
)
|
||||
""",
|
||||
(developer_id, developer_id),
|
||||
@@ -1493,8 +1493,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE developer_profiles
|
||||
SET plugin_count = ?, template_count = ?, total_downloads = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
SET plugin_count = ?, template_count = ?, total_downloads = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(
|
||||
plugin_row["count"],
|
||||
@@ -1583,7 +1583,7 @@ class DeveloperEcosystemManager:
|
||||
"""获取代码示例"""
|
||||
with self._get_db() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM code_examples WHERE id = ?", (example_id,)
|
||||
"SELECT * FROM code_examples WHERE id = ?", (example_id,)
|
||||
).fetchone()
|
||||
|
||||
if row:
|
||||
@@ -1602,13 +1602,13 @@ class DeveloperEcosystemManager:
|
||||
params = []
|
||||
|
||||
if language:
|
||||
query += " AND language = ?"
|
||||
query += " AND language = ?"
|
||||
params.append(language)
|
||||
if category:
|
||||
query += " AND category = ?"
|
||||
query += " AND category = ?"
|
||||
params.append(category)
|
||||
if sdk_id:
|
||||
query += " AND sdk_id = ?"
|
||||
query += " AND sdk_id = ?"
|
||||
params.append(sdk_id)
|
||||
if search:
|
||||
query += " AND (title LIKE ? OR description LIKE ? OR tags LIKE ?)"
|
||||
@@ -1626,8 +1626,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE code_examples
|
||||
SET view_count = view_count + 1
|
||||
WHERE id = ?
|
||||
SET view_count = view_count + 1
|
||||
WHERE id = ?
|
||||
""",
|
||||
(example_id,),
|
||||
)
|
||||
@@ -1639,8 +1639,8 @@ class DeveloperEcosystemManager:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE code_examples
|
||||
SET copy_count = copy_count + 1
|
||||
WHERE id = ?
|
||||
SET copy_count = copy_count + 1
|
||||
WHERE id = ?
|
||||
""",
|
||||
(example_id,),
|
||||
)
|
||||
@@ -1699,7 +1699,7 @@ class DeveloperEcosystemManager:
|
||||
"""获取 API 文档"""
|
||||
with self._get_db() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM api_documentation WHERE id = ?", (doc_id,)
|
||||
"SELECT * FROM api_documentation WHERE id = ?", (doc_id,)
|
||||
).fetchone()
|
||||
|
||||
if row:
|
||||
@@ -1799,7 +1799,7 @@ class DeveloperEcosystemManager:
|
||||
"""获取开发者门户配置"""
|
||||
with self._get_db() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM developer_portal_configs WHERE id = ?", (config_id,)
|
||||
"SELECT * FROM developer_portal_configs WHERE id = ?", (config_id,)
|
||||
).fetchone()
|
||||
|
||||
if row:
|
||||
@@ -1810,7 +1810,7 @@ class DeveloperEcosystemManager:
|
||||
"""获取活跃的开发者门户配置"""
|
||||
with self._get_db() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM developer_portal_configs WHERE is_active = 1 LIMIT 1"
|
||||
"SELECT * FROM developer_portal_configs WHERE is_active = 1 LIMIT 1"
|
||||
).fetchone()
|
||||
|
||||
if row:
|
||||
|
||||
Reference in New Issue
Block a user