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:
@@ -688,7 +688,7 @@ class EnterpriseManager:
|
||||
conn = self._get_connection()
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM sso_configs WHERE id = ?", (config_id,))
|
||||
cursor.execute("SELECT * FROM sso_configs WHERE id = ?", (config_id,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row:
|
||||
@@ -710,7 +710,7 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT * FROM sso_configs
|
||||
WHERE tenant_id = ? AND provider = ?
|
||||
WHERE tenant_id = ? AND provider = ?
|
||||
ORDER BY created_at DESC LIMIT 1
|
||||
""",
|
||||
(tenant_id, provider),
|
||||
@@ -719,7 +719,7 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT * FROM sso_configs
|
||||
WHERE tenant_id = ? AND status = 'active'
|
||||
WHERE tenant_id = ? AND status = 'active'
|
||||
ORDER BY created_at DESC LIMIT 1
|
||||
""",
|
||||
(tenant_id,),
|
||||
@@ -778,7 +778,7 @@ class EnterpriseManager:
|
||||
if not updates:
|
||||
return config
|
||||
|
||||
updates.append("updated_at = ?")
|
||||
updates.append("updated_at = ?")
|
||||
params.append(datetime.now())
|
||||
params.append(config_id)
|
||||
|
||||
@@ -786,7 +786,7 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
f"""
|
||||
UPDATE sso_configs SET {", ".join(updates)}
|
||||
WHERE id = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
params,
|
||||
)
|
||||
@@ -802,7 +802,7 @@ class EnterpriseManager:
|
||||
conn = self._get_connection()
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM sso_configs WHERE id = ?", (config_id,))
|
||||
cursor.execute("DELETE FROM sso_configs WHERE id = ?", (config_id,))
|
||||
conn.commit()
|
||||
return cursor.rowcount > 0
|
||||
finally:
|
||||
@@ -815,7 +815,7 @@ class EnterpriseManager:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT * FROM sso_configs WHERE tenant_id = ?
|
||||
SELECT * FROM sso_configs WHERE tenant_id = ?
|
||||
ORDER BY created_at DESC
|
||||
""",
|
||||
(tenant_id,),
|
||||
@@ -924,7 +924,7 @@ class EnterpriseManager:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT * FROM saml_auth_requests WHERE request_id = ?
|
||||
SELECT * FROM saml_auth_requests WHERE request_id = ?
|
||||
""",
|
||||
(request_id,),
|
||||
)
|
||||
@@ -1084,7 +1084,7 @@ class EnterpriseManager:
|
||||
conn = self._get_connection()
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM scim_configs WHERE id = ?", (config_id,))
|
||||
cursor.execute("SELECT * FROM scim_configs WHERE id = ?", (config_id,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row:
|
||||
@@ -1101,7 +1101,7 @@ class EnterpriseManager:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT * FROM scim_configs WHERE tenant_id = ?
|
||||
SELECT * FROM scim_configs WHERE tenant_id = ?
|
||||
ORDER BY created_at DESC LIMIT 1
|
||||
""",
|
||||
(tenant_id,),
|
||||
@@ -1146,7 +1146,7 @@ class EnterpriseManager:
|
||||
if not updates:
|
||||
return config
|
||||
|
||||
updates.append("updated_at = ?")
|
||||
updates.append("updated_at = ?")
|
||||
params.append(datetime.now())
|
||||
params.append(config_id)
|
||||
|
||||
@@ -1154,7 +1154,7 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
f"""
|
||||
UPDATE scim_configs SET {", ".join(updates)}
|
||||
WHERE id = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
params,
|
||||
)
|
||||
@@ -1180,8 +1180,8 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE scim_configs
|
||||
SET status = 'syncing', last_sync_at = ?
|
||||
WHERE id = ?
|
||||
SET status = 'syncing', last_sync_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(now, config_id),
|
||||
)
|
||||
@@ -1201,9 +1201,9 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE scim_configs
|
||||
SET status = 'active', last_sync_status = 'success',
|
||||
last_sync_error = NULL, last_sync_users_count = ?
|
||||
WHERE id = ?
|
||||
SET status = 'active', last_sync_status = 'success',
|
||||
last_sync_error = NULL, last_sync_users_count = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(synced_count, config_id),
|
||||
)
|
||||
@@ -1215,9 +1215,9 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE scim_configs
|
||||
SET status = 'error', last_sync_status = 'failed',
|
||||
last_sync_error = ?
|
||||
WHERE id = ?
|
||||
SET status = 'error', last_sync_status = 'failed',
|
||||
last_sync_error = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(str(e), config_id),
|
||||
)
|
||||
@@ -1257,16 +1257,16 @@ class EnterpriseManager:
|
||||
given_name, family_name, active, groups, raw_data, synced_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(tenant_id, external_id) DO UPDATE SET
|
||||
user_name = excluded.user_name,
|
||||
email = excluded.email,
|
||||
display_name = excluded.display_name,
|
||||
given_name = excluded.given_name,
|
||||
family_name = excluded.family_name,
|
||||
active = excluded.active,
|
||||
groups = excluded.groups,
|
||||
raw_data = excluded.raw_data,
|
||||
synced_at = excluded.synced_at,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
user_name = excluded.user_name,
|
||||
email = excluded.email,
|
||||
display_name = excluded.display_name,
|
||||
given_name = excluded.given_name,
|
||||
family_name = excluded.family_name,
|
||||
active = excluded.active,
|
||||
groups = excluded.groups,
|
||||
raw_data = excluded.raw_data,
|
||||
synced_at = excluded.synced_at,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
""",
|
||||
(
|
||||
str(uuid.uuid4()),
|
||||
@@ -1290,11 +1290,11 @@ class EnterpriseManager:
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
|
||||
query = "SELECT * FROM scim_users WHERE tenant_id = ?"
|
||||
query = "SELECT * FROM scim_users WHERE tenant_id = ?"
|
||||
params = [tenant_id]
|
||||
|
||||
if active_only:
|
||||
query += " AND active = 1"
|
||||
query += " AND active = 1"
|
||||
|
||||
query += " ORDER BY synced_at DESC"
|
||||
|
||||
@@ -1395,8 +1395,8 @@ class EnterpriseManager:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE audit_log_exports SET status = 'processing'
|
||||
WHERE id = ?
|
||||
UPDATE audit_log_exports SET status = 'processing'
|
||||
WHERE id = ?
|
||||
""",
|
||||
(export_id,),
|
||||
)
|
||||
@@ -1423,9 +1423,9 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE audit_log_exports
|
||||
SET status = 'completed', file_path = ?, file_size = ?,
|
||||
record_count = ?, checksum = ?, completed_at = ?
|
||||
WHERE id = ?
|
||||
SET status = 'completed', file_path = ?, file_size = ?,
|
||||
record_count = ?, checksum = ?, completed_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(file_path, file_size, len(logs), checksum, now, export_id),
|
||||
)
|
||||
@@ -1437,8 +1437,8 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE audit_log_exports
|
||||
SET status = 'failed', error_message = ?
|
||||
WHERE id = ?
|
||||
SET status = 'failed', error_message = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(str(e), export_id),
|
||||
)
|
||||
@@ -1523,7 +1523,7 @@ class EnterpriseManager:
|
||||
conn = self._get_connection()
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM audit_log_exports WHERE id = ?", (export_id,))
|
||||
cursor.execute("SELECT * FROM audit_log_exports WHERE id = ?", (export_id,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row:
|
||||
@@ -1541,7 +1541,7 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT * FROM audit_log_exports
|
||||
WHERE tenant_id = ?
|
||||
WHERE tenant_id = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT ?
|
||||
""",
|
||||
@@ -1562,8 +1562,8 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE audit_log_exports
|
||||
SET downloaded_by = ?, downloaded_at = ?
|
||||
WHERE id = ?
|
||||
SET downloaded_by = ?, downloaded_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(downloaded_by, datetime.now(), export_id),
|
||||
)
|
||||
@@ -1661,7 +1661,7 @@ class EnterpriseManager:
|
||||
conn = self._get_connection()
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM data_retention_policies WHERE id = ?", (policy_id,))
|
||||
cursor.execute("SELECT * FROM data_retention_policies WHERE id = ?", (policy_id,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row:
|
||||
@@ -1679,11 +1679,11 @@ class EnterpriseManager:
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
|
||||
query = "SELECT * FROM data_retention_policies WHERE tenant_id = ?"
|
||||
query = "SELECT * FROM data_retention_policies WHERE tenant_id = ?"
|
||||
params = [tenant_id]
|
||||
|
||||
if resource_type:
|
||||
query += " AND resource_type = ?"
|
||||
query += " AND resource_type = ?"
|
||||
params.append(resource_type)
|
||||
|
||||
query += " ORDER BY created_at DESC"
|
||||
@@ -1734,7 +1734,7 @@ class EnterpriseManager:
|
||||
if not updates:
|
||||
return policy
|
||||
|
||||
updates.append("updated_at = ?")
|
||||
updates.append("updated_at = ?")
|
||||
params.append(datetime.now())
|
||||
params.append(policy_id)
|
||||
|
||||
@@ -1742,7 +1742,7 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
f"""
|
||||
UPDATE data_retention_policies SET {", ".join(updates)}
|
||||
WHERE id = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
params,
|
||||
)
|
||||
@@ -1758,7 +1758,7 @@ class EnterpriseManager:
|
||||
conn = self._get_connection()
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM data_retention_policies WHERE id = ?", (policy_id,))
|
||||
cursor.execute("DELETE FROM data_retention_policies WHERE id = ?", (policy_id,))
|
||||
conn.commit()
|
||||
return cursor.rowcount > 0
|
||||
finally:
|
||||
@@ -1820,10 +1820,10 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE data_retention_jobs
|
||||
SET status = 'completed', completed_at = ?,
|
||||
affected_records = ?, archived_records = ?,
|
||||
deleted_records = ?, error_count = ?, details = ?
|
||||
WHERE id = ?
|
||||
SET status = 'completed', completed_at = ?,
|
||||
affected_records = ?, archived_records = ?,
|
||||
deleted_records = ?, error_count = ?, details = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(
|
||||
datetime.now(),
|
||||
@@ -1840,8 +1840,8 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE data_retention_policies
|
||||
SET last_executed_at = ?, last_execution_result = 'success'
|
||||
WHERE id = ?
|
||||
SET last_executed_at = ?, last_execution_result = 'success'
|
||||
WHERE id = ?
|
||||
""",
|
||||
(datetime.now(), policy_id),
|
||||
)
|
||||
@@ -1852,8 +1852,8 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE data_retention_jobs
|
||||
SET status = 'failed', completed_at = ?, error_count = 1, details = ?
|
||||
WHERE id = ?
|
||||
SET status = 'failed', completed_at = ?, error_count = 1, details = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(datetime.now(), json.dumps({"error": str(e)}), job_id),
|
||||
)
|
||||
@@ -1861,8 +1861,8 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE data_retention_policies
|
||||
SET last_executed_at = ?, last_execution_result = ?
|
||||
WHERE id = ?
|
||||
SET last_executed_at = ?, last_execution_result = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(datetime.now(), str(e), policy_id),
|
||||
)
|
||||
@@ -1927,7 +1927,7 @@ class EnterpriseManager:
|
||||
conn = self._get_connection()
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM data_retention_jobs WHERE id = ?", (job_id,))
|
||||
cursor.execute("SELECT * FROM data_retention_jobs WHERE id = ?", (job_id,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
if row:
|
||||
@@ -1945,7 +1945,7 @@ class EnterpriseManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT * FROM data_retention_jobs
|
||||
WHERE policy_id = ?
|
||||
WHERE policy_id = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT ?
|
||||
""",
|
||||
|
||||
Reference in New Issue
Block a user