Skip to content

Commit

Permalink
feat(scheduler): add admin permission to allow schedulable tasks exec…
Browse files Browse the repository at this point in the history
…ution through api
  • Loading branch information
Anuj-Gupta4 committed Feb 19, 2025
1 parent 7638062 commit 3863064
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/backend/app/tasks/task_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
from psycopg import Connection

from app.auth.auth_schemas import ProjectUserDict
from app.auth.roles import mapper
from app.auth.roles import mapper, super_admin
from app.db.database import db_conn
from app.db.enums import HTTPStatus
from app.db.models import DbTask, DbTaskEvent
from app.db.models import DbTask, DbTaskEvent, DbUser
from app.tasks import task_crud, task_schemas

router = APIRouter(
Expand Down Expand Up @@ -118,7 +118,10 @@ async def get_task_event_history(


@router.post("/unlock-tasks")
async def unlock_tasks(db: Annotated[Connection, Depends(db_conn)]):
async def unlock_tasks(
db: Annotated[Connection, Depends(db_conn)],
current_user: Annotated[DbUser, Depends(super_admin)],
):
"""Endpoint to trigger unlock_old_locked_tasks manually."""
log.info("Start processing inactive tasks")
await task_crud.trigger_unlock_tasks(db)
Expand Down
3 changes: 3 additions & 0 deletions src/backend/app/users/user_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ async def delete_user_by_identifier(
@router.post("/process-inactive-users")
async def delete_inactive_users(
db: Annotated[Connection, Depends(db_conn)],
current_user: Annotated[DbUser, Depends(super_admin)],
):
"""Identify inactive users, send warnings, and delete accounts."""
log.info("Start processing inactive users")
await process_inactive_users(db)
log.info("Finished processing inactive users")
return Response(status_code=HTTPStatus.NO_CONTENT)

0 comments on commit 3863064

Please sign in to comment.