тест 6

This commit is contained in:
2026-05-15 14:19:26 +03:00
parent 761f46a932
commit d8a31442c9
4 changed files with 80 additions and 4 deletions

35
app.py
View File

@@ -1404,7 +1404,40 @@ def vmix_standings(session_token: str):
for row in rows
]
class MatchChannelPayload(BaseModel):
match_external_id: str
channel: str = ""
@app.post("/admin/session/{session_token}/schedule/channel")
def update_schedule_channel(session_token: str, payload: MatchChannelPayload):
session_row = get_match_session_by_token(session_token)
if not session_row:
return JSONResponse({"error": "session_not_found"}, status_code=404)
allowed = {"", "match", "match_premier", "match_and_premier"}
if payload.channel not in allowed:
return JSONResponse({"error": "invalid_channel"}, status_code=400)
conn = get_connection()
try:
with conn.cursor() as cur:
cur.execute(
"""
UPDATE matches
SET channel = %s
WHERE external_id = %s
""",
(payload.channel, payload.match_external_id),
)
conn.commit()
return {"success": True}
except Exception as e:
conn.rollback()
return JSONResponse({"error": str(e)}, status_code=500)
finally:
conn.close()
@app.get("/vmix/session/{session_token}/schedule")
def vmix_schedule(session_token: str):
session_row = get_match_session_by_token(session_token)
@@ -1431,7 +1464,7 @@ def vmix_schedule(session_token: str):
),
"mask_time": "#FFFFFF00" if row[2] is not None and row[3] is not None else "#FFFFFF",
"mask_score": "#FFFFFF00" if row[2] is None and row[3] is None else "#FFFFFF",
"channel": row[6] or "",
"channel": row[7] or "",
}
for row in rows
]