feat: Hide leaderboards, add healthz endpoint and seed script
This commit is contained in:
parent
d257698539
commit
df586b7c4e
3 changed files with 71 additions and 4 deletions
|
|
@ -38,3 +38,9 @@ app.include_router(stats.router)
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
def read_root():
|
def read_root():
|
||||||
return {"Hello": "World"}
|
return {"Hello": "World"}
|
||||||
|
|
||||||
|
@app.get("/healthz")
|
||||||
|
def health_check():
|
||||||
|
"""Health check endpoint for monitoring and load balancers"""
|
||||||
|
return {"status": "healthy"}
|
||||||
|
|
||||||
|
|
|
||||||
64
backend/seed_ratings.py
Normal file
64
backend/seed_ratings.py
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
"""
|
||||||
|
Seed script to create demo ratings for shows and performances.
|
||||||
|
Run with: python seed_ratings.py
|
||||||
|
"""
|
||||||
|
from sqlmodel import Session, create_engine, select
|
||||||
|
from database import DATABASE_URL
|
||||||
|
from models import Rating, Show, Performance, User
|
||||||
|
import random
|
||||||
|
|
||||||
|
def seed_ratings():
|
||||||
|
engine = create_engine(DATABASE_URL)
|
||||||
|
|
||||||
|
with Session(engine) as session:
|
||||||
|
# Get first user (or admin) to attribute ratings to
|
||||||
|
user = session.exec(select(User).limit(1)).first()
|
||||||
|
if not user:
|
||||||
|
print("No users found. Please create a user first.")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Get some shows
|
||||||
|
shows = session.exec(select(Show).limit(20)).all()
|
||||||
|
# Get some performances
|
||||||
|
performances = session.exec(select(Performance).limit(50)).all()
|
||||||
|
|
||||||
|
created_count = 0
|
||||||
|
|
||||||
|
# Seed show ratings (7-10 range for positive feel)
|
||||||
|
for show in shows:
|
||||||
|
# Check if rating already exists
|
||||||
|
existing = session.exec(
|
||||||
|
select(Rating).where(Rating.show_id == show.id, Rating.user_id == user.id)
|
||||||
|
).first()
|
||||||
|
if existing:
|
||||||
|
continue
|
||||||
|
|
||||||
|
rating = Rating(
|
||||||
|
user_id=user.id,
|
||||||
|
show_id=show.id,
|
||||||
|
score=random.randint(7, 10)
|
||||||
|
)
|
||||||
|
session.add(rating)
|
||||||
|
created_count += 1
|
||||||
|
|
||||||
|
# Seed performance ratings
|
||||||
|
for perf in performances:
|
||||||
|
existing = session.exec(
|
||||||
|
select(Rating).where(Rating.performance_id == perf.id, Rating.user_id == user.id)
|
||||||
|
).first()
|
||||||
|
if existing:
|
||||||
|
continue
|
||||||
|
|
||||||
|
rating = Rating(
|
||||||
|
user_id=user.id,
|
||||||
|
performance_id=perf.id,
|
||||||
|
score=random.randint(6, 10)
|
||||||
|
)
|
||||||
|
session.add(rating)
|
||||||
|
created_count += 1
|
||||||
|
|
||||||
|
session.commit()
|
||||||
|
print(f"Created {created_count} demo ratings!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
seed_ratings()
|
||||||
|
|
@ -48,10 +48,7 @@ export function Navbar() {
|
||||||
<Link href="/tours">
|
<Link href="/tours">
|
||||||
<DropdownMenuItem>Tours</DropdownMenuItem>
|
<DropdownMenuItem>Tours</DropdownMenuItem>
|
||||||
</Link>
|
</Link>
|
||||||
<DropdownMenuSeparator />
|
{/* Leaderboards hidden until community activity grows */}
|
||||||
<Link href="/leaderboards">
|
|
||||||
<DropdownMenuItem>Leaderboards</DropdownMenuItem>
|
|
||||||
</Link>
|
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue