feat(config): add live slow-sql threshold setting
This commit is contained in:
@@ -17,6 +17,7 @@ _DEFAULT_SYSTEM_CONFIG = {
|
||||
"max_concurrent_global": 2,
|
||||
"max_concurrent_per_account": 1,
|
||||
"max_screenshot_concurrent": 3,
|
||||
"db_slow_query_ms": 120,
|
||||
"schedule_enabled": 0,
|
||||
"schedule_time": "02:00",
|
||||
"schedule_browse_type": "应读",
|
||||
@@ -49,6 +50,7 @@ _SYSTEM_CONFIG_UPDATERS = (
|
||||
("schedule_weekdays", "schedule_weekdays"),
|
||||
("max_concurrent_per_account", "max_concurrent_per_account"),
|
||||
("max_screenshot_concurrent", "max_screenshot_concurrent"),
|
||||
("db_slow_query_ms", "db_slow_query_ms"),
|
||||
("enable_screenshot", "enable_screenshot"),
|
||||
("proxy_enabled", "proxy_enabled"),
|
||||
("proxy_api_url", "proxy_api_url"),
|
||||
@@ -265,6 +267,7 @@ def update_system_config(
|
||||
kdocs_admin_notify_email=None,
|
||||
kdocs_row_start=None,
|
||||
kdocs_row_end=None,
|
||||
db_slow_query_ms=None,
|
||||
) -> bool:
|
||||
"""更新系统配置(仅更新DB,不做缓存处理)。"""
|
||||
arg_values = {
|
||||
@@ -293,6 +296,7 @@ def update_system_config(
|
||||
"kdocs_admin_notify_email": kdocs_admin_notify_email,
|
||||
"kdocs_row_start": kdocs_row_start,
|
||||
"kdocs_row_end": kdocs_row_end,
|
||||
"db_slow_query_ms": db_slow_query_ms,
|
||||
}
|
||||
|
||||
updates = []
|
||||
|
||||
@@ -74,6 +74,7 @@ def _get_migration_steps():
|
||||
(17, _migrate_to_v17),
|
||||
(18, _migrate_to_v18),
|
||||
(19, _migrate_to_v19),
|
||||
(20, _migrate_to_v20),
|
||||
]
|
||||
|
||||
|
||||
@@ -884,3 +885,21 @@ def _migrate_to_v19(conn):
|
||||
cursor.execute(statement)
|
||||
|
||||
conn.commit()
|
||||
|
||||
|
||||
|
||||
def _migrate_to_v20(conn):
|
||||
"""迁移到版本20 - 慢SQL阈值系统配置"""
|
||||
cursor = conn.cursor()
|
||||
|
||||
columns = _get_table_columns(cursor, "system_config")
|
||||
_add_column_if_missing(
|
||||
cursor,
|
||||
"system_config",
|
||||
columns,
|
||||
"db_slow_query_ms",
|
||||
"INTEGER DEFAULT 120",
|
||||
ok_message=" [OK] 添加 system_config.db_slow_query_ms 字段",
|
||||
)
|
||||
|
||||
conn.commit()
|
||||
|
||||
@@ -210,6 +210,7 @@ def ensure_schema(conn) -> None:
|
||||
proxy_expire_minutes INTEGER DEFAULT 3,
|
||||
max_screenshot_concurrent INTEGER DEFAULT 3,
|
||||
max_concurrent_per_account INTEGER DEFAULT 1,
|
||||
db_slow_query_ms INTEGER DEFAULT 120,
|
||||
schedule_weekdays TEXT DEFAULT '1,2,3,4,5,6,7',
|
||||
enable_screenshot INTEGER DEFAULT 1,
|
||||
auto_approve_enabled INTEGER DEFAULT 0,
|
||||
|
||||
Reference in New Issue
Block a user