Add a more helpful docstring to schedule logic, scheduled test

This commit is contained in:
shamoon
2025-05-27 09:16:27 -07:00
parent 2ada8ec681
commit f39463ff4e
2 changed files with 62 additions and 1 deletions

View File

@@ -387,6 +387,18 @@ def empty_trash(doc_ids=None):
@shared_task
def check_scheduled_workflows():
"""
Check and run all enabled scheduled workflows.
Scheduled triggers are evaluated based on a target date field (e.g. added, created, modified, or a custom date field),
combined with a day offset.
The offset is mathematically negated resulting in the following behavior:
- Positive offsets mean the workflow should trigger BEFORE the specified date (e.g., offset = +7 → trigger 7 days before)
- Negative offsets mean the workflow should trigger AFTER the specified date (e.g., offset = -7 → trigger 7 days after)
Once a document satisfies this condition, and recurring/non-recurring constraints are met, the workflow is run.
"""
scheduled_workflows: list[Workflow] = (
Workflow.objects.filter(
triggers__type=WorkflowTrigger.WorkflowTriggerType.SCHEDULED,