diff --git a/agent.py b/agent.py index c69c7b3..6707002 100644 --- a/agent.py +++ b/agent.py @@ -10,8 +10,8 @@ import requests import websockets VMIX_API = "http://127.0.0.1:8088/api" -# WS_BASE = "wss://hostname.tvstart.ru/ws/vmix-client" -WS_BASE = "ws://127.0.0.1:8000/ws/vmix-client" +WS_BASE = "wss://wfl.tvstart.ru/ws/vmix-client" +# WS_BASE = "ws://127.0.0.1:8000/ws/vmix-client" CLIENT_ID = f"vmix-{socket.gethostname().lower()}-{uuid.uuid4().hex[:6]}" POLL_INTERVAL = 3 diff --git a/app.py b/app.py index 04fa0a2..1e5dd2e 100644 --- a/app.py +++ b/app.py @@ -459,8 +459,15 @@ def admin_matches( request: Request, today_only: bool = Query(default=False), tour: str | None = Query(default=None), + hide_finished: str = Query(default="true"), ): - matches = list_matches_for_admin(today_only=today_only, tour=tour) + hide_finished_bool = str(hide_finished).lower() == "true" + + matches = list_matches_for_admin( + today_only=today_only, + tour=tour, + hide_finished=hide_finished_bool, + ) tours = list_available_tours() return templates.TemplateResponse( @@ -469,13 +476,14 @@ def admin_matches( context={ "matches": matches, "today_only": today_only, + "hide_finished": hide_finished_bool, "selected_tour": tour or "", "tours": tours, "current_user": getattr(request.state, "current_user", None), }, ) - - + + # @app.get("/admin/matches/{match_id}/select") # def select_match( # request: Request, match_id: int, operator_name: str = Form(default="") @@ -519,7 +527,7 @@ def select_match( session_row = create_match_session( match_id=match_id, - operator_name=operator_name.strip() or None, + operator_name=None, vmix_project_path=None, ) @@ -533,7 +541,7 @@ def select_match( match_id=match_id, session_token=session_token, details={ - "operator_name": operator_name.strip() or None, + "operator_name": None, }, ) @@ -1354,7 +1362,7 @@ EMPTY_PLAYER_FORMATION = { "number": " ", "number_lastname_amp_K": " ", "position": " ", - "photo": " ", + "photo": r"D:\Графика\ФУТБОЛ\Женская Суперлига 2026\Photo\EMPTY.png", } diff --git a/repositories/__pycache__/match_session_repository.cpython-312.pyc b/repositories/__pycache__/match_session_repository.cpython-312.pyc index 39fba5b..cd6c5b2 100644 Binary files a/repositories/__pycache__/match_session_repository.cpython-312.pyc and b/repositories/__pycache__/match_session_repository.cpython-312.pyc differ diff --git a/repositories/match_session_repository.py b/repositories/match_session_repository.py index 9ba0497..2ab5b7e 100644 --- a/repositories/match_session_repository.py +++ b/repositories/match_session_repository.py @@ -207,3 +207,45 @@ def list_available_tours(): return tours finally: conn.close() + +def list_matches_for_admin( + today_only: bool = False, + tour: str | None = None, + hide_finished: bool = True, +): + query = """ + SELECT + m.id, + m.external_id, + m.match_date, + m.status, + m.tour, + m.season, + ht.name AS home_team_name, + at.name AS away_team_name + FROM matches m + JOIN teams ht ON ht.id = m.home_team_id + JOIN teams at ON at.id = m.away_team_id + WHERE 1=1 + """ + params = [] + + if today_only: + query += " AND DATE(m.match_date) = CURRENT_DATE " + + if tour: + query += " AND m.tour = %s " + params.append(tour) + + if hide_finished: + query += " AND COALESCE(m.status, 'scheduled') <> 'finished' " + + query += " ORDER BY m.match_date ASC NULLS LAST, m.id ASC; " + + conn = get_connection() + try: + with conn.cursor() as cur: + cur.execute(query, params) + return cur.fetchall() + finally: + conn.close() \ No newline at end of file diff --git a/scripts/__pycache__/create_admin.cpython-312.pyc b/scripts/__pycache__/create_admin.cpython-312.pyc index 1a9135d..00e7e56 100644 Binary files a/scripts/__pycache__/create_admin.cpython-312.pyc and b/scripts/__pycache__/create_admin.cpython-312.pyc differ diff --git a/scripts/create_admin.py b/scripts/create_admin.py index 6a397e3..6e7aed9 100644 --- a/scripts/create_admin.py +++ b/scripts/create_admin.py @@ -1,23 +1,13 @@ import os import sys from getpass import getpass +from db import get_connection sys.path.append(os.path.dirname(os.path.dirname(__file__))) -import psycopg2 from services.auth_service import hash_password -def get_connection(): - return psycopg2.connect( - host=os.getenv("DB_HOST", "localhost"), - port=os.getenv("DB_PORT", 5432), - dbname=os.getenv("DB_NAME", "wfl_db"), - user=os.getenv("DB_USER", "postgres"), - password=os.getenv("DB_PASSWORD", "159753"), - ) - - def main(): username = input("Username: ").strip() password = getpass("Password: ").strip() diff --git a/templates/matches.html b/templates/matches.html index 937ab57..f84d070 100644 --- a/templates/matches.html +++ b/templates/matches.html @@ -345,6 +345,21 @@ +