🔍 Code Extractor

function get_document_review_cycles_v1

Maturity: 43

Retrieves all review cycles associated with a specific document, with an option to filter for only active cycles.

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

Purpose

This function serves as a controller endpoint to fetch review cycle information for a given document in a controlled document management system. It delegates to an underlying controller to retrieve review cycles, which are used to track document review processes, approvals, and feedback. The function supports filtering to return only active review cycles when needed, making it useful for both historical auditing and current workflow management.

Source Code

def get_document_review_cycles(document_uid: str, include_active_only: bool = False) -> Dict[str, Any]:
    """Get all review cycles for a document."""
    return _controller.get_cycles_for_document(document_uid, include_active_only)

Parameters

Name Type Default Kind
document_uid str - positional_or_keyword
include_active_only bool False positional_or_keyword

Parameter Details

document_uid: A unique identifier (string) for the document whose review cycles are being retrieved. This should be a valid UID that exists in the system's document database. Used to query and filter review cycles associated with this specific document.

include_active_only: A boolean flag (defaults to False) that determines whether to return all review cycles or only those that are currently active. When True, filters out completed, cancelled, or inactive review cycles. When False (default), returns the complete history of all review cycles for the document.

Return Value

Type: Dict[str, Any]

Returns a dictionary (Dict[str, Any]) containing review cycle data for the specified document. The dictionary structure likely includes keys for review cycle metadata such as cycle IDs, status, reviewers, dates, comments, and other workflow-related information. The exact structure depends on the underlying _controller.get_cycles_for_document implementation but follows a flexible key-value format to accommodate various review cycle attributes.

Dependencies

  • CDocs
  • typing
  • datetime
  • logging

Required Imports

from typing import Dict, Any
from CDocs.controllers import log_controller_action

Usage Example

# Assuming the function is imported from its module
from CDocs.controllers.review_controller import get_document_review_cycles

# Get all review cycles for a document
document_id = "doc-12345-abcde"
all_cycles = get_document_review_cycles(document_id)
print(f"Total review cycles: {len(all_cycles.get('cycles', []))}")

# Get only active review cycles
active_cycles = get_document_review_cycles(document_id, include_active_only=True)
for cycle in active_cycles.get('cycles', []):
    print(f"Active cycle: {cycle.get('id')} - Status: {cycle.get('status')}")

# Handle potential errors
try:
    cycles = get_document_review_cycles("invalid-doc-id")
except ResourceNotFoundError:
    print("Document not found")
except PermissionError:
    print("Insufficient permissions to view review cycles")

Best Practices

  • Always validate that the document_uid exists before calling this function to avoid ResourceNotFoundError exceptions
  • Use include_active_only=True when you only need current workflow information to reduce data transfer and processing
  • Handle potential exceptions (ResourceNotFoundError, PermissionError) that may be raised by the underlying controller
  • The function is decorated with log_controller_action, so all calls are automatically logged for audit purposes
  • Consider caching results if calling this function repeatedly for the same document within a short time period
  • Ensure the user has appropriate permissions to view review cycles for the specified document
  • The returned dictionary structure may vary; always check for key existence before accessing nested data

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_document_approval_cycles_v1 84.8% similar

    Retrieves all approval cycles associated with a specific document, with an option to filter for only active cycles.

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

    Retrieves all review cycles associated with a specific document, with optional filtering for active cycles only.

    From: /tf/active/vicechatdev/CDocs/controllers/review_controller.py
  • function get_review_v1 80.4% similar

    Retrieves a specific review cycle by its unique identifier (UID) from the document review system.

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

    Creates a review cycle for a specific document version, assigning reviewers with configurable approval requirements and workflow settings.

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

    Retrieves a review cycle record from the database using its unique identifier (UID).

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