Task Operations

Task management operations.

async shared.database.operations.task.create_user_task_with_queue(user, description)[source]

Create a new user task and add it to the processing queue.

Parameters:
  • user (User) – User instance

  • description (str) – Task description

Return type:

Tuple[UserTask, TaskQueue]

Returns:

Tuple of (UserTask, TaskQueue)

async shared.database.operations.task.deactivate_user_tasks(user_id)[source]

Deactivate all active tasks for a user.

Parameters:

user_id (int) – Internal user ID

Return type:

None

async shared.database.operations.task.get_most_recent_active_user_task()[source]

Return the most recently updated active user task, or None if none exist.

Return type:

Optional[UserTask]

Returns:

A single UserTask instance or None when no active tasks.

async shared.database.operations.task.get_user_tasks(user_id)[source]

Get all tasks for a user with eager loading to avoid lazy loading issues.

Parameters:

user_id (int) – Internal user ID

Return type:

List[UserTask]

Returns:

List of UserTask instances

async shared.database.operations.task.list_active_user_tasks()[source]

List all active user tasks.

Return type:

List[UserTask]

Returns:

List of active UserTask instances

async shared.database.operations.task.list_user_tasks(user_id)[source]

List all tasks for a user.

Parameters:

user_id (int) – Internal user ID

Return type:

List[UserTask]

Returns:

List of UserTask instances

async shared.database.operations.task.update_user_task_status(task_id, status)[source]

Update task status.

Parameters:
Return type:

None

async shared.database.operations.task.update_user_task_status_for_user(user_id, task_id, status)[source]

Safely update task status ensuring ownership by user.

Parameters:
  • user_id (int) – Internal user ID

  • task_id (int) – Task ID

  • status (TaskStatus) – New status

Return type:

bool

Returns:

True if updated successfully, False if user not found