finally, queue logic
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
from fastapi import Depends
|
||||
from fastapi import Depends, HTTPException, status
|
||||
from typing import Annotated
|
||||
from sqlalchemy.orm import Session
|
||||
from uuid import UUID
|
||||
|
||||
from ...dependencies import get_db
|
||||
from ...db import models
|
||||
@ -28,3 +29,25 @@ def create_queue(
|
||||
db.add(q)
|
||||
db.commit()
|
||||
return schemas.QueueInDb.model_validate(q)
|
||||
|
||||
|
||||
def get_detailed_queue(
|
||||
queue_id: UUID,
|
||||
db: Annotated[Session, Depends(get_db)],
|
||||
) -> schemas.QueueDetail:
|
||||
q = db.query(models.Queue).filter(models.Queue.id == queue_id).first()
|
||||
print("\n\n", queue_id, "\n\n", flush=True)
|
||||
if q:
|
||||
return schemas.QueueDetail(
|
||||
id=q.id,
|
||||
name=q.name,
|
||||
description=q.description,
|
||||
participants=schemas.ParticipantInfo(
|
||||
total=q.users.count(),
|
||||
remaining=q.users.filter(models.QueueUser.passed == False).count(),
|
||||
),
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Not Found",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user