diff --git a/sessions/__pycache__/models.cpython-39.pyc b/sessions/__pycache__/models.cpython-39.pyc index 36bd28c..8c1f8f5 100644 Binary files a/sessions/__pycache__/models.cpython-39.pyc and b/sessions/__pycache__/models.cpython-39.pyc differ diff --git a/sessions/__pycache__/routes.cpython-39.pyc b/sessions/__pycache__/routes.cpython-39.pyc index 9ccd5fc..d5eae08 100644 Binary files a/sessions/__pycache__/routes.cpython-39.pyc and b/sessions/__pycache__/routes.cpython-39.pyc differ diff --git a/sessions/routes.py b/sessions/routes.py index 2320c67..9cb8544 100644 --- a/sessions/routes.py +++ b/sessions/routes.py @@ -3,6 +3,7 @@ from deps.auth.auth import get_current_user from uuid import uuid4 from app.db import db +from datetime import datetime, timezone # nest sessions in the database like: @@ -36,6 +37,14 @@ async def get_sessions(user=Depends(get_current_user)): return sessions +@router.get("/active_sessions", status_code=200) +async def get_active_sessions(): + sessions = db["sessions"].find({"end_time": {"$gte": datetime.now(tz=timezone.utc)}}) + if sessions: + return list(sessions) + return [] + + @router.get("/{id}", status_code=200) async def get_single_session(id: str, user=Depends(get_current_user)): session = db["sessions"].find_one({"_id": id})