[功能] 服务状态页新增「视频分割」状态 - Oracle /api/oracle/activity 加 segment(运动片段 done/pending/failed/文件数/最近分割活动), ServiceStatus.vue 加视频分割卡片
This commit is contained in:
@@ -153,9 +153,20 @@ def activity():
|
||||
model_calls = db._conn.execute(
|
||||
"SELECT id, provider, model, filename, started_at, duration_sec, "
|
||||
"success, error FROM model_calls ORDER BY id DESC LIMIT 5").fetchall()
|
||||
# 运动片段分割状态(服务状态页「视频分割」卡)
|
||||
segment = db.get_segment_status()
|
||||
try:
|
||||
import os
|
||||
from ..config_loader import load_config
|
||||
seg_dir = load_config().get('motion_segment', {}).get(
|
||||
'clips_dir', '/opt/fam-edge/motion_clips')
|
||||
segment['clips_files'] = len(os.listdir(seg_dir)) if os.path.isdir(seg_dir) else 0
|
||||
except Exception:
|
||||
segment['clips_files'] = 0
|
||||
return jsonify({
|
||||
"queue": q_status,
|
||||
"db": db.get_queue_status(),
|
||||
"segment": segment,
|
||||
"rclone": _last_activity('rclone'),
|
||||
"person": _last_activity('person'),
|
||||
"model_calls": [dict(m) for m in model_calls],
|
||||
|
||||
@@ -369,6 +369,35 @@ class OracleDB:
|
||||
"recent": [dict(r) for r in recent],
|
||||
}
|
||||
|
||||
def get_segment_status(self) -> Dict:
|
||||
"""运动片段分割状态(前端服务状态页「视频分割」卡)。
|
||||
|
||||
统计 motion_event_id 非空的运动片段记录 + 最近分割活动。
|
||||
"""
|
||||
seg_sql = "FROM videos WHERE motion_event_id IS NOT NULL"
|
||||
total = self._conn.execute(f"SELECT COUNT(*) c {seg_sql}").fetchone()['c']
|
||||
done = self._conn.execute(
|
||||
f"SELECT COUNT(*) c {seg_sql} AND status='done'").fetchone()['c']
|
||||
pending = self._conn.execute(
|
||||
f"SELECT COUNT(*) c {seg_sql} AND status='pending'").fetchone()['c']
|
||||
failed = self._conn.execute(
|
||||
f"SELECT COUNT(*) c {seg_sql} AND status='failed'").fetchone()['c']
|
||||
# 已分割事件数(videos.motion_event_id 去重)与待分割事件数(ss_motion_events 未生成片段)
|
||||
motion_total = self._conn.execute(
|
||||
"SELECT COUNT(*) c FROM ss_motion_events WHERE event_type=10 AND COALESCE(duration,0)>0"
|
||||
).fetchone()['c']
|
||||
last = self._conn.execute(
|
||||
"SELECT service, action, detail, ts FROM service_activity "
|
||||
"WHERE service='segment' ORDER BY id DESC LIMIT 1").fetchone()
|
||||
return {
|
||||
"total": total,
|
||||
"done": done,
|
||||
"pending": pending,
|
||||
"failed": failed,
|
||||
"motion_events": motion_total,
|
||||
"last": dict(last) if last else None,
|
||||
}
|
||||
|
||||
def set_video_file_status(self, video_id: int, valid: bool,
|
||||
error: str = '', media_meta: dict = None):
|
||||
"""登记/更新文件校验结果:valid / file_error / media_meta_json"""
|
||||
|
||||
Reference in New Issue
Block a user