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:
@@ -176,8 +176,28 @@ def get_video_url_exists(video_path: str) -> bool:
|
||||
# ============================================================
|
||||
|
||||
def _dt_or_none(value):
|
||||
"""datetime 字段归一化: 空串/None → NULL(MariaDB 严格模式拒绝 '' 插入 DATETIME 列)"""
|
||||
return value if value else None
|
||||
"""datetime 字段归一化(MariaDB 严格模式兼容)
|
||||
|
||||
- 空串/None/'None'/'null' → NULL
|
||||
- ISO 8601(2026-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,
|
||||
|
||||
Reference in New Issue
Block a user