From 3621997088401585ca4614b7bfedf32de67d2785 Mon Sep 17 00:00:00 2001 From: Frikky Date: Fri, 25 Oct 2024 16:15:46 +0200 Subject: [PATCH] Added CheckNextActions() notes for @yashsinghcodes --- db-connector.go | 1 + shared.go | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/db-connector.go b/db-connector.go index 0eb62de..b4bea6f 100755 --- a/db-connector.go +++ b/db-connector.go @@ -1572,6 +1572,7 @@ func GetExecutionVariables(ctx context.Context, executionId string) (string, int cacheData := []byte(cache.([]uint8)) err = json.Unmarshal(cacheData, &wrapper) if err == nil { + return wrapper.StartNode, wrapper.Extra, wrapper.Children, wrapper.Parents, wrapper.Visited, wrapper.Executed, wrapper.NextActions, wrapper.Environments } } else { diff --git a/shared.go b/shared.go index 2be1f05..a4710f7 100755 --- a/shared.go +++ b/shared.go @@ -23555,7 +23555,24 @@ func CheckNextActions(ctx context.Context, workflowExecution *WorkflowExecution) nextActions = findMissingChildren(ctx, workflowExecution, children, inputNode, []string{}) - //log.Printf("[DEBUG][%s] Checking what are next actions in workflow %s. Results: %d/%d. NextActions: %s", workflowExecution.ExecutionId, workflowExecution.ExecutionId, len(workflowExecution.Results), len(workflowExecution.Workflow.Actions)+extra, nextActions) + // SHOULD WE: Write code here which returns IF an action should be SKIPPED. If ALL parents are SKIPPED/FAILED, return something like []string{id:SKIPPED} -> parent function that calls this should make it SKIPPED + // Question: Should we just run SKIPPED requests directly from here, then NOT return the ID? + + // Skipped request info: + // Look into sendSelfRequest AND areas where we send requests for ActionResult to self: + /* + ActionResult{ + Action: curaction, + ExecutionId: workflowExecution.ExecutionId, + Authorization: workflowExecution.Authorization, + Result: `{"success": false, "reason": "Skipped because it's not under the startnode (1)"}`, + StartedAt: 0, + CompletedAt: 0, + Status: "SKIPPED", + } + */ + + return nextActions } @@ -23580,6 +23597,10 @@ func DecideExecution(ctx context.Context, workflowExecution WorkflowExecution, e } } + if len(nextActions) == 0 { + nextActions = CheckNextActions(ctx, &workflowExecution) + } + // Dedup results just in case newResults := []ActionResult{} handled := []string{}