fix: MCP server SQL uses correct column names (video_id, not pipeline_run_id)
This commit is contained in:
parent
6375ce667e
commit
f27c18b555
1 changed files with 7 additions and 10 deletions
|
|
@ -608,14 +608,13 @@ def recent_events(limit: int = 20, video_id: str = "", stage: str = "") -> str:
|
||||||
pe.prompt_tokens, pe.completion_tokens, pe.duration_ms,
|
pe.prompt_tokens, pe.completion_tokens, pe.duration_ms,
|
||||||
pe.created_at, sv.filename
|
pe.created_at, sv.filename
|
||||||
FROM pipeline_events pe
|
FROM pipeline_events pe
|
||||||
LEFT JOIN pipeline_runs pr ON pe.pipeline_run_id = pr.id
|
LEFT JOIN source_videos sv ON pe.video_id = sv.id
|
||||||
LEFT JOIN source_videos sv ON pr.source_video_id = sv.id
|
|
||||||
"""
|
"""
|
||||||
conditions = []
|
conditions = []
|
||||||
params: list = []
|
params: list = []
|
||||||
|
|
||||||
if video_id:
|
if video_id:
|
||||||
conditions.append("pr.source_video_id = %s")
|
conditions.append("pe.video_id = %s")
|
||||||
params.append(video_id)
|
params.append(video_id)
|
||||||
if stage:
|
if stage:
|
||||||
conditions.append("pe.stage = %s")
|
conditions.append("pe.stage = %s")
|
||||||
|
|
@ -640,12 +639,11 @@ def token_usage(video_id: str = "", stage: str = "") -> str:
|
||||||
coalesce(sum(pe.completion_tokens), 0) as total_completion_tokens,
|
coalesce(sum(pe.completion_tokens), 0) as total_completion_tokens,
|
||||||
coalesce(sum(pe.prompt_tokens), 0) + coalesce(sum(pe.completion_tokens), 0) as total_tokens
|
coalesce(sum(pe.prompt_tokens), 0) + coalesce(sum(pe.completion_tokens), 0) as total_tokens
|
||||||
FROM pipeline_events pe
|
FROM pipeline_events pe
|
||||||
LEFT JOIN pipeline_runs pr ON pe.pipeline_run_id = pr.id
|
|
||||||
WHERE pe.event_type = 'llm_call'
|
WHERE pe.event_type = 'llm_call'
|
||||||
"""
|
"""
|
||||||
params: list = []
|
params: list = []
|
||||||
if video_id:
|
if video_id:
|
||||||
sql += " AND pr.source_video_id = %s"
|
sql += " AND pe.video_id = %s"
|
||||||
params.append(video_id)
|
params.append(video_id)
|
||||||
if stage:
|
if stage:
|
||||||
sql += " AND pe.stage = %s"
|
sql += " AND pe.stage = %s"
|
||||||
|
|
@ -662,16 +660,15 @@ def token_usage(video_id: str = "", stage: str = "") -> str:
|
||||||
def processing_times(limit: int = 10) -> str:
|
def processing_times(limit: int = 10) -> str:
|
||||||
"""Processing duration for recent pipeline runs (start to last event)."""
|
"""Processing duration for recent pipeline runs (start to last event)."""
|
||||||
rows = _query("""
|
rows = _query("""
|
||||||
SELECT pr.id, sv.filename, c.name as creator,
|
SELECT pe.video_id, sv.filename, c.name as creator,
|
||||||
min(pe.created_at) as started_at,
|
min(pe.created_at) as started_at,
|
||||||
max(pe.created_at) as finished_at,
|
max(pe.created_at) as finished_at,
|
||||||
EXTRACT(EPOCH FROM (max(pe.created_at) - min(pe.created_at)))::int as duration_seconds,
|
EXTRACT(EPOCH FROM (max(pe.created_at) - min(pe.created_at)))::int as duration_seconds,
|
||||||
count(pe.id) as event_count
|
count(pe.id) as event_count
|
||||||
FROM pipeline_runs pr
|
FROM pipeline_events pe
|
||||||
JOIN source_videos sv ON pr.source_video_id = sv.id
|
JOIN source_videos sv ON pe.video_id = sv.id
|
||||||
LEFT JOIN creators c ON sv.creator_id = c.id
|
LEFT JOIN creators c ON sv.creator_id = c.id
|
||||||
JOIN pipeline_events pe ON pe.pipeline_run_id = pr.id
|
GROUP BY pe.video_id, sv.filename, c.name
|
||||||
GROUP BY pr.id, sv.filename, c.name
|
|
||||||
ORDER BY max(pe.created_at) DESC
|
ORDER BY max(pe.created_at) DESC
|
||||||
LIMIT %s
|
LIMIT %s
|
||||||
""", (limit,))
|
""", (limit,))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue