fediversion/backend/fix_tours.py
fullsizemalt b4cddf41ea feat: Initialize Fediversion multi-band platform
- Fork elmeg-demo codebase for multi-band support
- Add data importer infrastructure with base class
- Create band-specific importers:
  - phish.py: Phish.net API v5
  - grateful_dead.py: Grateful Stats API
  - setlistfm.py: Dead & Company, Billy Strings (Setlist.fm)
- Add spec-kit configuration for Gemini
- Update README with supported bands and architecture
2025-12-28 12:39:28 -08:00

29 lines
965 B
Python

from sqlmodel import Session, select, func
from database import engine
from models import Tour, Show
def fix_tour_dates():
with Session(engine) as session:
tours = session.exec(select(Tour)).all()
print(f"Fixing dates for {len(tours)} tours...")
for tour in tours:
# Find min/max show date
result = session.exec(
select(func.min(Show.date), func.max(Show.date))
.where(Show.tour_id == tour.id)
).first()
if result and result[0]:
tour.start_date = result[0]
tour.end_date = result[1]
session.add(tour)
# print(f" {tour.name}: {tour.start_date.date()} - {tour.end_date.date()}")
# else:
# print(f" {tour.name}: No shows found")
session.commit()
print("Done.")
if __name__ == "__main__":
fix_tour_dates()