Skip to content

Commit

Permalink
Update items.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfemir authored Nov 16, 2024
1 parent 01fdb9d commit 256fb13
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/routers/secure/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,18 +517,25 @@ async def get_all_paused(
):
"""Get all paused media items, optionally filtered by type"""
# Use raw SQL to verify data
sql = "SELECT id, title, type, is_paused, paused_at FROM \"MediaItem\" WHERE is_paused = true"
query = select(
MediaItem.id,
MediaItem.title,
MediaItem.type,
MediaItem.is_paused,
MediaItem.paused_at
).where(MediaItem.is_paused.is_(True))

if type:
valid_types = [t.value for t in MediaType]
if type not in valid_types:
raise HTTPException(
status_code=400,
detail=f"Invalid type. Must be one of: {', '.join(valid_types)}"
)
sql += f" AND type = '{type}'"
query = query.where(MediaItem.type == type)

logger.debug(f"Executing SQL: {sql}")
result = db.execute(sql)
logger.debug(f"Executing query: {str(query)}")
result = db.execute(query)
rows = result.fetchall()
logger.debug(f"Raw SQL found {len(rows)} rows")

Expand Down

0 comments on commit 256fb13

Please sign in to comment.