Skip to content

Commit

Permalink
Minor more fixes for execution loading
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed Nov 6, 2024
1 parent 48c15b0 commit 12c424f
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions db-connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,7 @@ func GetWorkflowExecution(ctx context.Context, id string) (*WorkflowExecution, e
nameKey := "workflowexecution"
cacheKey := fmt.Sprintf("%s_%s", nameKey, id)

// Loads of cache management to ensure we have the latest version of the execution no matter what
workflowExecution := &WorkflowExecution{}
if project.CacheDb {
cache, err := GetCache(ctx, cacheKey)
Expand Down Expand Up @@ -2124,7 +2125,7 @@ func GetWorkflowExecution(ctx context.Context, id string) (*WorkflowExecution, e

wrapped := ExecWrapper{}
err = json.Unmarshal(respBody, &wrapped)
if err != nil {
if err != nil && len(wrapped.Source.ExecutionId) == 0 {
return workflowExecution, err
}

Expand Down Expand Up @@ -4690,7 +4691,7 @@ func GetSession(ctx context.Context, thissession string) (*Session, error) {
func DeleteKey(ctx context.Context, entity string, value string) error {
// Non indexed User data
if entity == "workflowexecution" {
log.Printf("[WARNING] Deleting workflowexecution: %s", value)
log.Printf("[WARNING] DELETING workflowexecution: %s", value)
}

DeleteCache(ctx, fmt.Sprintf("%s_%s", entity, value))
Expand Down Expand Up @@ -10659,12 +10660,11 @@ func GetUnfinishedExecutions(ctx context.Context, workflowId string) ([]Workflow
_, err := it.Next(&innerWorkflow)
if err != nil {
// log.Printf("[WARNING] Error for %s: %s", cacheKey, err)
break
//if strings.Contains(fmt.Sprintf("%s", err), "cannot load field") {
//} else {
// //log.Printf("[WARNING] Workflow iterator issue: %s", err)
// break
//}
if strings.Contains(fmt.Sprintf("%s", err), "cannot load field") {
} else {
//log.Printf("[WARNING] Workflow iterator issue: %s", err)
break
}
}

executions = append(executions, innerWorkflow)
Expand Down Expand Up @@ -10807,7 +10807,7 @@ func GetAllWorkflowExecutionsV2(ctx context.Context, workflowId string, amount i

wrapped := ExecutionSearchWrapper{}
err = json.Unmarshal(respBody, &wrapped)
if err != nil {
if err != nil && len(wrapped.Hits.Hits) == 0{
return executions, cursor, err
}

Expand Down Expand Up @@ -11168,7 +11168,7 @@ func GetAllWorkflowExecutions(ctx context.Context, workflowId string, amount int

wrapped := ExecutionSearchWrapper{}
err = json.Unmarshal(respBody, &wrapped)
if err != nil {
if err != nil && len(wrapped.Hits.Hits) == 0 {
return executions, err
}

Expand Down Expand Up @@ -11196,8 +11196,11 @@ func GetAllWorkflowExecutions(ctx context.Context, workflowId string, amount int
innerWorkflow := WorkflowExecution{}
_, err := it.Next(&innerWorkflow)
if err != nil {
//log.Printf("[WARNING] Error getting workflow executions: %s", err)
break
if strings.Contains(fmt.Sprintf("%s", err), "cannot load field") {
} else {
log.Printf("[WARNING] CreateValue iterator issue: %s", err)
break
}
}

executions = append(executions, innerWorkflow)
Expand Down Expand Up @@ -13397,7 +13400,7 @@ func GetWorkflowRunsBySearch(ctx context.Context, orgId string, search WorkflowS

wrapped := ExecutionSearchWrapper{}
err = json.Unmarshal(respBody, &wrapped)
if err != nil {
if err != nil && len(wrapped.Hits.Hits) == 0 {
return executions, "", err
}

Expand Down

0 comments on commit 12c424f

Please sign in to comment.