🔍 Code Extractor

function get_user_assigned_reviews_v1

Maturity: 55

Retrieves all review assignments for a specific user, with optional filtering by status and inclusion of completed reviews.

File:
/tf/active/vicechatdev/CDocs single class/controllers/review_controller.py
Lines:
1855 - 1867
Complexity:
simple

Purpose

This function serves as a controller endpoint to fetch review assignments for a given user in a document review workflow system. It provides a paginated list of assignments with configurable status filtering, defaulting to only active reviews (PENDING and IN_PROGRESS) unless explicitly requested otherwise. The function is decorated with logging capabilities and integrates with an underlying controller to retrieve assignment data.

Source Code

def get_user_assigned_reviews(user: DocUser, status_filter: Optional[List[str]] = None, 
                              include_completed: bool = False) -> Dict[str, Any]:
    """Get all reviews assigned to a user."""
    if not include_completed and not status_filter:
        status_filter = ["PENDING", "IN_PROGRESS"]
        
    assignments, total = _controller.get_assignments_for_user(
        user_uid=user.uid if user else None,
        status_filter=status_filter,
        limit=100,
        offset=0
    )
    return {"success": True, "assignments": assignments, "total": total}

Parameters

Name Type Default Kind
user DocUser - positional_or_keyword
status_filter Optional[List[str]] None positional_or_keyword
include_completed bool False positional_or_keyword

Parameter Details

user: A DocUser object representing the user whose review assignments should be retrieved. The function extracts the user's UID to query assignments. If None, the underlying controller will handle the null user case.

status_filter: Optional list of status strings to filter assignments. Common values include 'PENDING', 'IN_PROGRESS', 'COMPLETED', 'REJECTED'. If None and include_completed is False, defaults to ['PENDING', 'IN_PROGRESS']. If provided, overrides the default filtering behavior.

include_completed: Boolean flag that determines whether completed reviews should be included in results. When False (default) and no status_filter is provided, automatically filters to only PENDING and IN_PROGRESS statuses. When True without a status_filter, all statuses are returned.

Return Value

Type: Dict[str, Any]

Returns a dictionary with three keys: 'success' (boolean, always True on successful execution), 'assignments' (list of assignment objects/dictionaries containing review assignment details), and 'total' (integer representing the total count of assignments matching the filter criteria). The assignments list is limited to 100 items per the hardcoded limit parameter.

Dependencies

  • CDocs

Required Imports

from typing import Dict, List, Any, Optional
from CDocs.models.user_extensions import DocUser
from CDocs.controllers import log_controller_action

Usage Example

from CDocs.models.user_extensions import DocUser
from your_module import get_user_assigned_reviews

# Get a user object (assume user is already authenticated/loaded)
user = DocUser.query.filter_by(email='reviewer@example.com').first()

# Get only active reviews (default behavior)
result = get_user_assigned_reviews(user)
print(f"Found {result['total']} active assignments")
for assignment in result['assignments']:
    print(f"Assignment ID: {assignment['id']}, Status: {assignment['status']}")

# Get all reviews including completed ones
result_all = get_user_assigned_reviews(user, include_completed=True)

# Get only pending reviews
result_pending = get_user_assigned_reviews(user, status_filter=['PENDING'])

# Get completed and rejected reviews
result_custom = get_user_assigned_reviews(
    user, 
    status_filter=['COMPLETED', 'REJECTED']
)

Best Practices

  • Always pass a valid DocUser object; passing None may result in unexpected behavior depending on the underlying controller implementation
  • Be aware that results are limited to 100 assignments; implement pagination if more results are needed by modifying the hardcoded limit
  • The function always returns success=True; error handling should be implemented at a higher level or the underlying _controller.get_assignments_for_user may raise exceptions
  • When using status_filter, ensure status values match the expected enum values in AssignmentStatus model
  • The include_completed parameter only affects behavior when status_filter is None; if status_filter is explicitly provided, include_completed is ignored
  • Consider the performance implications of the hardcoded limit=100 and offset=0 for users with many assignments
  • The log_controller_action decorator will automatically log this function's execution; ensure logging is properly configured

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_user_assigned_reviews 92.8% similar

    Retrieves all review assignments for a specific user with optional filtering by status, including associated review cycle, document, and version details.

    From: /tf/active/vicechatdev/CDocs/controllers/review_controller.py
  • function get_user_pending_reviews_v1 89.2% similar

    Retrieves pending review assignments for a specific user, with an option to include completed reviews.

    From: /tf/active/vicechatdev/CDocs single class/controllers/review_controller.py
  • function get_user_assigned_approvals_v2 79.7% similar

    Retrieves all approval assignments for a specific user, with optional filtering by status and inclusion of completed approvals.

    From: /tf/active/vicechatdev/CDocs single class/controllers/approval_controller.py
  • function get_user_assigned_approvals_v1 77.2% similar

    Retrieves all approval assignments for a specific user with optional filtering by status, including associated approval cycles, documents, and version information.

    From: /tf/active/vicechatdev/CDocs/controllers/approval_controller.py
  • function get_user_pending_reviews 76.1% similar

    Retrieves all pending (and optionally completed) document reviews assigned to a specific user, with support for date filtering and pagination.

    From: /tf/active/vicechatdev/CDocs/controllers/review_controller.py
← Back to Browse