diff --git a/backend/app/api/screen.py b/backend/app/api/screen.py index 0c6c506..e0edfb9 100644 --- a/backend/app/api/screen.py +++ b/backend/app/api/screen.py @@ -15,8 +15,11 @@ router = APIRouter(prefix="/screen", tags=["screen"]) @router.get("/court/{court_id}") def get_court_display(court_id: int, db: Session = Depends(get_db)): - """Full court display data for TV screen""" - court = db.query(Court).filter(Court.id == court_id).first() + """Full court display data for TV screen (court_id = court_number)""" + # Try by court_number first (friendlier URLs), then by id + court = db.query(Court).filter(Court.court_number == court_id).first() + if not court: + court = db.query(Court).filter(Court.id == court_id).first() if not court: return {"error": "Court not found"} diff --git a/backend/seed.py b/backend/seed.py index 0449ca2..8b52c3c 100644 --- a/backend/seed.py +++ b/backend/seed.py @@ -23,6 +23,14 @@ def clear_data(db: Session): db.query(Court).delete() db.query(Player).delete() db.commit() + # Reset sequences + for table in ['players', 'courts', 'bookings', 'matches', 'match_players', + 'tournaments', 'tournament_entries', 'tournament_matches']: + try: + db.execute(__import__('sqlalchemy').text(f"ALTER SEQUENCE {table}_id_seq RESTART WITH 1")) + except Exception: + pass + db.commit() print("Cleared existing data")