fix(db): frame_timestamp ISO8601 归一化 + perf(edge): ollama num_predict 1024→512

- db_layer._dt_or_none 支持 ISO 8601(带 T/Z/时区偏移) 归一化为 MariaDB DATETIME 标准格式, 修复 1292 Incorrect datetime value
- edge config ollama num_predict 512: qwen2.5:7b 在 ARM 上 1024 token 融合需 200s, 降到 512 加速且输出足够
This commit is contained in:
ericwyuan
2026-08-20 09:26:42 +08:00
parent d2fd01f134
commit 486eee4feb
2 changed files with 23 additions and 3 deletions

View File

@@ -176,8 +176,28 @@ def get_video_url_exists(video_path: str) -> bool:
# ============================================================ # ============================================================
def _dt_or_none(value): def _dt_or_none(value):
"""datetime 字段归一化: 空串/None → NULLMariaDB 严格模式拒绝 '' 插入 DATETIME 列)""" """datetime 字段归一化MariaDB 严格模式兼容)
return value if value else None
- 空串/None/'None'/'null' → NULL
- ISO 86012026-08-20T01:06:44Z / 2026-08-20T01:06:44.123+00:00'2026-08-20 01:06:44'
- 已为标准格式则原样返回
"""
if value is None:
return None
s = str(value).strip()
if s in ('', 'None', 'null', 'NaN'):
return None
# 归一化 ISO 8601 -> 'YYYY-MM-DD HH:MM:SS'
s2 = s.replace('T', ' ').replace('Z', '').replace('z', '')
if '+' in s2[10:]:
s2 = s2[:s2.index('+')]
if '.' in s2:
s2 = s2[:s2.index('.')]
try:
dt = datetime.strptime(s2, '%Y-%m-%d %H:%M:%S')
return dt.strftime('%Y-%m-%d %H:%M:%S')
except Exception:
return None
def insert_event(task_id: int, event_start_time: str, event_end_time: str, def insert_event(task_id: int, event_start_time: str, event_end_time: str,

View File

@@ -72,6 +72,6 @@ models:
model_name: "qwen2.5:7b" model_name: "qwen2.5:7b"
base_url: "http://localhost:11434" base_url: "http://localhost:11434"
timeout: 300 timeout: 300
num_predict: 1024 num_predict: 512
circuit_breaker: circuit_breaker:
enabled: false enabled: false