Spaces:
Paused
Paused
| from fastapi import APIRouter, Depends, HTTPException, status | |
| from sqlalchemy.orm import Session | |
| from typing import Any, Dict | |
| from app.db.database import get_db | |
| from app.db import models, schemas | |
| from app.core.dependencies import get_current_active_user | |
| router = APIRouter( | |
| prefix="/api/sessions", | |
| tags=["sessions"] | |
| ) | |
| def update_iteration_status( | |
| session_update: schemas.SessionUpdate, | |
| current_user: models.User = Depends(get_current_active_user), | |
| db: Session = Depends(get_db) | |
| ) -> Dict[str, bool]: | |
| """Update the iteration status of the current session.""" | |
| session = db.query(models.Session).filter( | |
| models.Session.user_id == current_user.id | |
| ).first() | |
| if not session: | |
| raise HTTPException(status_code=404, detail="Active session not found") | |
| session.iteration_active = session_update.iteration_active | |
| db.commit() | |
| return {"iteration_active": session.iteration_active} |