"""
Add more sporting events to the database
"""
import asyncio
from datetime import datetime, timedelta
from sqlalchemy import select

from app.database import async_session
from app.models import User, SportEvent, SportType, EventStatus


async def add_events():
    """Add more sporting events"""
    async with async_session() as db:
        # Get admin user
        result = await db.execute(select(User).where(User.is_admin == True))
        admin = result.scalar_one_or_none()

        if not admin:
            print("No admin user found!")
            return

        print("Adding more sporting events...")

        events = [
            # NFL Games
            SportEvent(
                sport=SportType.FOOTBALL,
                home_team="Philadelphia Eagles",
                away_team="Dallas Cowboys",
                official_spread=-3.5,
                game_time=datetime.utcnow() + timedelta(hours=12),
                venue="Lincoln Financial Field",
                league="NFL",
                min_spread=-14.0,
                max_spread=14.0,
                min_bet_amount=10.0,
                max_bet_amount=2000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.FOOTBALL,
                home_team="San Francisco 49ers",
                away_team="Seattle Seahawks",
                official_spread=-7.0,
                game_time=datetime.utcnow() + timedelta(hours=20),
                venue="Levi's Stadium",
                league="NFL",
                min_spread=-14.0,
                max_spread=14.0,
                min_bet_amount=10.0,
                max_bet_amount=2000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.FOOTBALL,
                home_team="Green Bay Packers",
                away_team="Chicago Bears",
                official_spread=-6.5,
                game_time=datetime.utcnow() + timedelta(days=2, hours=5),
                venue="Lambeau Field",
                league="NFL",
                min_spread=-14.0,
                max_spread=14.0,
                min_bet_amount=10.0,
                max_bet_amount=2000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.FOOTBALL,
                home_team="Miami Dolphins",
                away_team="New York Jets",
                official_spread=-4.0,
                game_time=datetime.utcnow() + timedelta(days=2, hours=8),
                venue="Hard Rock Stadium",
                league="NFL",
                min_spread=-14.0,
                max_spread=14.0,
                min_bet_amount=10.0,
                max_bet_amount=2000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),

            # NBA Games
            SportEvent(
                sport=SportType.BASKETBALL,
                home_team="Golden State Warriors",
                away_team="Phoenix Suns",
                official_spread=-2.5,
                game_time=datetime.utcnow() + timedelta(hours=6),
                venue="Chase Center",
                league="NBA",
                min_spread=-15.0,
                max_spread=15.0,
                min_bet_amount=10.0,
                max_bet_amount=1000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.BASKETBALL,
                home_team="Milwaukee Bucks",
                away_team="Cleveland Cavaliers",
                official_spread=-4.0,
                game_time=datetime.utcnow() + timedelta(hours=10),
                venue="Fiserv Forum",
                league="NBA",
                min_spread=-15.0,
                max_spread=15.0,
                min_bet_amount=10.0,
                max_bet_amount=1000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.BASKETBALL,
                home_team="Denver Nuggets",
                away_team="Oklahoma City Thunder",
                official_spread=-1.5,
                game_time=datetime.utcnow() + timedelta(days=1, hours=5),
                venue="Ball Arena",
                league="NBA",
                min_spread=-15.0,
                max_spread=15.0,
                min_bet_amount=10.0,
                max_bet_amount=1000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.BASKETBALL,
                home_team="Miami Heat",
                away_team="New York Knicks",
                official_spread=2.0,
                game_time=datetime.utcnow() + timedelta(days=1, hours=8),
                venue="Kaseya Center",
                league="NBA",
                min_spread=-15.0,
                max_spread=15.0,
                min_bet_amount=10.0,
                max_bet_amount=1000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),

            # NHL Games
            SportEvent(
                sport=SportType.HOCKEY,
                home_team="Toronto Maple Leafs",
                away_team="Montreal Canadiens",
                official_spread=-1.5,
                game_time=datetime.utcnow() + timedelta(hours=4),
                venue="Scotiabank Arena",
                league="NHL",
                min_spread=-5.0,
                max_spread=5.0,
                min_bet_amount=10.0,
                max_bet_amount=500.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.HOCKEY,
                home_team="Vegas Golden Knights",
                away_team="Colorado Avalanche",
                official_spread=-0.5,
                game_time=datetime.utcnow() + timedelta(hours=16),
                venue="T-Mobile Arena",
                league="NHL",
                min_spread=-5.0,
                max_spread=5.0,
                min_bet_amount=10.0,
                max_bet_amount=500.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.HOCKEY,
                home_team="Boston Bruins",
                away_team="New York Rangers",
                official_spread=-1.0,
                game_time=datetime.utcnow() + timedelta(days=1, hours=2),
                venue="TD Garden",
                league="NHL",
                min_spread=-5.0,
                max_spread=5.0,
                min_bet_amount=10.0,
                max_bet_amount=500.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),

            # Soccer Games
            SportEvent(
                sport=SportType.SOCCER,
                home_team="Manchester United",
                away_team="Liverpool",
                official_spread=0.5,
                game_time=datetime.utcnow() + timedelta(hours=14),
                venue="Old Trafford",
                league="Premier League",
                min_spread=-3.0,
                max_spread=3.0,
                min_bet_amount=10.0,
                max_bet_amount=1000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.SOCCER,
                home_team="Real Madrid",
                away_team="Barcelona",
                official_spread=-0.5,
                game_time=datetime.utcnow() + timedelta(days=2, hours=10),
                venue="Santiago Bernabeu",
                league="La Liga",
                min_spread=-3.0,
                max_spread=3.0,
                min_bet_amount=10.0,
                max_bet_amount=1000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.SOCCER,
                home_team="Bayern Munich",
                away_team="Borussia Dortmund",
                official_spread=-1.0,
                game_time=datetime.utcnow() + timedelta(days=3, hours=8),
                venue="Allianz Arena",
                league="Bundesliga",
                min_spread=-3.0,
                max_spread=3.0,
                min_bet_amount=10.0,
                max_bet_amount=1000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),

            # College Football
            SportEvent(
                sport=SportType.FOOTBALL,
                home_team="Alabama",
                away_team="Georgia",
                official_spread=2.5,
                game_time=datetime.utcnow() + timedelta(days=4, hours=12),
                venue="Mercedes-Benz Stadium",
                league="NCAA Football",
                min_spread=-14.0,
                max_spread=14.0,
                min_bet_amount=10.0,
                max_bet_amount=1000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.FOOTBALL,
                home_team="Ohio State",
                away_team="Michigan",
                official_spread=-3.0,
                game_time=datetime.utcnow() + timedelta(days=5, hours=6),
                venue="Ohio Stadium",
                league="NCAA Football",
                min_spread=-14.0,
                max_spread=14.0,
                min_bet_amount=10.0,
                max_bet_amount=1000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
            SportEvent(
                sport=SportType.FOOTBALL,
                home_team="Texas",
                away_team="Oklahoma",
                official_spread=-1.5,
                game_time=datetime.utcnow() + timedelta(days=6, hours=10),
                venue="Cotton Bowl",
                league="NCAA Football",
                min_spread=-14.0,
                max_spread=14.0,
                min_bet_amount=10.0,
                max_bet_amount=1000.0,
                created_by=admin.id,
                status=EventStatus.UPCOMING
            ),
        ]

        for event in events:
            db.add(event)

        await db.commit()

        print(f"Added {len(events)} new events!")
        print("\nEvents added:")
        for e in events:
            print(f"  - {e.home_team} vs {e.away_team} ({e.league})")


if __name__ == "__main__":
    asyncio.run(add_events())
