function get_document_review_cycles_v1
Retrieves all review cycles associated with a specific document, with an option to filter for only active cycles.
/tf/active/vicechatdev/CDocs single class/controllers/review_controller.py
1799 - 1801
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
CDocstypingdatetimelogging
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
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function get_document_approval_cycles_v1 84.8% similar
-
function get_document_review_cycles 80.5% similar
-
function get_review_v1 80.4% similar
-
function create_review_cycle_v1 76.6% similar
-
function get_review_cycle_v1 75.5% similar