fix(roi):修复 working_hours 为空数组 [] 时被错误识别为 None 的问题,导致全天模式失效。
Some checks failed
Python Test / test (push) Has been cancelled

- 修改 `api/roi.py` 中的判断逻辑:使用 `is not None` 替代 truthy 检查,确保 `[]` 能正确序列化并存入数据库
- 更新 `config.yaml` 全局默认值为 `working_hours: []`,表示“全天开启”
This commit is contained in:
2026-01-22 18:02:19 +08:00
parent 3af7a0f805
commit 44b6c70a4b
2 changed files with 4 additions and 8 deletions

View File

@@ -108,7 +108,7 @@ def add_roi(
): ):
import json import json
working_hours_json = json.dumps(request.working_hours) if request.working_hours else None working_hours_json = json.dumps(request.working_hours) if request.working_hours is not None else None
roi = create_roi( roi = create_roi(
db, db,
@@ -153,7 +153,7 @@ def modify_roi(
db: Session = Depends(get_db), db: Session = Depends(get_db),
): ):
import json import json
working_hours_json = json.dumps(request.working_hours) if request.working_hours else None working_hours_json = json.dumps(request.working_hours) if request.working_hours is not None else None
roi = update_roi( roi = update_roi(
db, db,

View File

@@ -60,12 +60,8 @@ roi:
- "line" - "line"
max_points: 50 # 多边形最大顶点数 max_points: 50 # 多边形最大顶点数
# 工作时间配置(全局默认) # 工作时间配置(全局默认,空数组表示全天开启
working_hours: working_hours: []
- start: [8, 30] # 8:30
end: [11, 0] # 11:00
- start: [12, 0] # 12:00
end: [17, 30] # 17:30
# 算法默认参数 # 算法默认参数
algorithms: algorithms: