docs + #1042
Some checks are pending
URL Path Check / check-url-paths (push) Waiting to run
docker / docker_dev (push) Waiting to run
Deploy MkDocs / deploy (push) Waiting to run

This commit is contained in:
jokob-sk
2025-04-05 08:04:31 +11:00
parent ffb0d0238d
commit a12da278c6
11 changed files with 95 additions and 10 deletions

View File

@@ -50,23 +50,24 @@ class WorkflowManager:
def process_event(self, event):
"""Process the events. Check if events match a workflow trigger"""
guid = event["GUID"]
mylog('verbose', [f"[WF] Processing event with GUID {guid}"])
evGuid = event["GUID"]
mylog('verbose', [f"[WF] Processing event with GUID {evGuid}"])
# Check if the trigger conditions match
for workflow in self.workflows:
# Ensure workflow is enabled before proceeding
if workflow.get("enabled", "No").lower() == "yes":
mylog('debug', [f"[WF] Checking if '{event["GUID"]}' triggers the workflow '{workflow["name"]}'"])
wfName = workflow["name"]
mylog('debug', [f"[WF] Checking if '{evGuid}' triggers the workflow '{wfName}'"])
# construct trigger object which also evaluates if the current event triggers it
trigger = Trigger(workflow["trigger"], event, self.db)
if trigger.triggered:
mylog('verbose', [f"[WF] Event with GUID '{event["GUID"]}' triggered the workflow '{workflow["name"]}'"])
mylog('verbose', [f"[WF] Event with GUID '{evGuid}' triggered the workflow '{wfName}'"])
self.execute_workflow(workflow, trigger)
@@ -83,6 +84,8 @@ class WorkflowManager:
def execute_workflow(self, workflow, trigger):
"""Execute the actions in the given workflow if conditions are met."""
wfName = workflow["name"]
# Ensure conditions exist
if not isinstance(workflow.get("conditions"), list):
m = f"[WF] workflow['conditions'] must be a list"
@@ -96,7 +99,7 @@ class WorkflowManager:
if evaluator.evaluate(trigger): # If any group evaluates to True
mylog('none', [f"[WF] Workflow {workflow["name"]} will be executed - conditions were evaluated as TRUE"])
mylog('none', [f"[WF] Workflow {wfName} will be executed - conditions were evaluated as TRUE"])
mylog('debug', [f"[WF] Workflow condition_group: {condition_group}"])
self.execute_actions(workflow["actions"], trigger)