"""
Seed all major jam bands for Fediversion
Comprehensive list based on Nugs.net catalog
"""
from sqlmodel import Session, select
from database import engine
from models import Vertical

# Major jam bands - based on Nugs.net catalog
BANDS = [
    # Tier 1 - The big names
    {"name": "Phish", "slug": "phish", "description": "Vermont-based jam band formed in 1983. One of the most influential live acts in music history.", "is_featured": True},
    {"name": "Goose", "slug": "goose", "description": "Connecticut jam band formed in 2014. Known for improvisational rock and explosive live shows.", "is_featured": True},
    {"name": "Billy Strings", "slug": "billy-strings", "description": "Grammy-winning bluegrass musician from Michigan. Blends traditional bluegrass with progressive elements.", "is_featured": True},
    {"name": "Dave Matthews Band", "slug": "dmb", "description": "Iconic jam band from Charlottesville, VA. Known for saxophone-driven rock and massive touring.", "is_featured": True},
    {"name": "Widespread Panic", "slug": "widespread-panic", "description": "Southern rock jam band from Athens, GA. Touring since 1986 with devoted fanbase.", "is_featured": True},
    {"name": "Umphrey's McGee", "slug": "umphreys-mcgee", "description": "Progressive jam band from South Bend, IN. Known for technical proficiency and genre-blending.", "is_featured": True},
    {"name": "Dead & Company", "slug": "dead-and-company", "description": "Grateful Dead members with John Mayer. Carrying on the Dead legacy since 2015.", "is_featured": True},
    {"name": "The String Cheese Incident", "slug": "sci", "description": "Colorado jam band formed in 1993. Known for bluegrass-infused improvisational rock.", "is_featured": True},
    
    # Tier 2 - Popular touring acts
    {"name": "My Morning Jacket", "slug": "mmj", "description": "Louisville rock band led by Jim James. Known for epic live performances.", "is_featured": True},
    {"name": "Greensky Bluegrass", "slug": "greensky-bluegrass", "description": "Michigan bluegrass band. Progressive approach to traditional bluegrass.", "is_featured": False},
    {"name": "Pigeons Playing Ping Pong", "slug": "pigeons", "description": "Baltimore funk-rock jam band. High energy shows with funky grooves.", "is_featured": False},
    {"name": "Lotus", "slug": "lotus", "description": "Electronic jam band from Indiana/Colorado. Livetronica pioneers.", "is_featured": False},
    {"name": "Joe Russo's Almost Dead", "slug": "jrad", "description": "Grateful Dead tribute supergroup. Known for creative Dead reinterpretations.", "is_featured": False},
    {"name": "Twiddle", "slug": "twiddle", "description": "Vermont jam band formed at Castleton State. Progressive jam rock.", "is_featured": False},
    {"name": "Spafford", "slug": "spafford", "description": "Arizona jam band. Known for extended improvisations and dedicated fanbase.", "is_featured": False},
    {"name": "Dopapod", "slug": "dopapod", "description": "Keytar-driven jam band. Blend of electronica, prog, and funk.", "is_featured": False},
    {"name": "Aqueous", "slug": "aqueous", "description": "Buffalo-based jam rock band. Progressive rock with heavy improvisation.", "is_featured": False},
    {"name": "Eggy", "slug": "eggy", "description": "New England jam band. Rising stars in the scene.", "is_featured": False},
    {"name": "Dogs in a Pile", "slug": "dogs-in-a-pile", "description": "New Jersey jam band. Young and energetic.", "is_featured": False},
    {"name": "Kitchen Dwellers", "slug": "kitchen-dwellers", "description": "Montana bluegrass-jam band. Galaxy Grass pioneers.", "is_featured": False},
    
    # Classic/Legacy acts
    {"name": "Grateful Dead", "slug": "grateful-dead", "description": "The legendary San Francisco band (1965-1995). Foundation of the jam band scene.", "is_featured": True},
    {"name": "The Allman Brothers Band", "slug": "allman-brothers", "description": "Southern rock pioneers from Macon, GA. Legendary improvisational rock.", "is_featured": False},
    
    # Additional popular acts
    {"name": "Khruangbin", "slug": "khruangbin", "description": "Houston trio. Global funk and psychedelic grooves.", "is_featured": False},
    {"name": "Vampire Weekend", "slug": "vampire-weekend", "description": "Indie rock band from NYC. Art rock with world music influences.", "is_featured": False},
    {"name": "King Gizzard & The Lizard Wizard", "slug": "king-gizzard", "description": "Australian psychedelic rock band. Prolific and genre-defying.", "is_featured": False},
]


def seed_all_bands():
    with Session(engine) as session:
        added = 0
        skipped = 0
        
        for band_data in BANDS:
            existing = session.exec(
                select(Vertical).where(Vertical.slug == band_data["slug"])
            ).first()
            
            if existing:
                print(f"✓ {band_data['name']} already exists")
                skipped += 1
                continue
            
            vertical = Vertical(
                name=band_data["name"],
                slug=band_data["slug"],
                description=band_data["description"],
                is_active=True,
                is_featured=band_data.get("is_featured", False)
            )
            session.add(vertical)
            print(f"✅ Added: {band_data['name']}")
            added += 1
        
        session.commit()
        
        # Show totals
        all_verts = session.exec(select(Vertical).where(Vertical.is_active == True)).all()
        print(f"\n{'='*50}")
        print(f"📊 Added: {added} | Skipped: {skipped}")
        print(f"📊 Total active bands: {len(all_verts)}")
        print(f"{'='*50}")
        
        featured = [v for v in all_verts if v.is_featured]
        print(f"\n⭐ Featured bands ({len(featured)}):")
        for v in featured:
            print(f"   - {v.name}")


if __name__ == "__main__":
    seed_all_bands()
