From d13249d87dedd1cfe37ac1b2c53f83cb9b8a9a32 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 20 Aug 2024 15:31:25 +0200 Subject: [PATCH] correct is DC link --- models/workflow/workflow_mongo_accessor.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/models/workflow/workflow_mongo_accessor.go b/models/workflow/workflow_mongo_accessor.go index b5eb408..e6c1657 100644 --- a/models/workflow/workflow_mongo_accessor.go +++ b/models/workflow/workflow_mongo_accessor.go @@ -140,7 +140,14 @@ func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*w func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delete bool) (int, error) { if realData.Schedule == nil && realData.ScheduleActive { - return 200, nil + res, code, err := wfa.LoadOne(id) + if code == 200 { + r := res.(*Workflow) + if r.Schedule != nil { + err = wfa.book(id, r, []*workflow_execution.WorkflowExecution{}) + } + } + return 200, err } if realData.Schedule == nil && !realData.ScheduleActive { mongo.MONGOService.DeleteMultiple(map[string]interface{}{ @@ -150,7 +157,10 @@ func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delet err := wfa.book(id, realData, []*workflow_execution.WorkflowExecution{}) return 200, err } - res, _, _ := wfa.LoadOne(id) + res, code, _ := wfa.LoadOne(id) + if code != 200 { + return 404, errors.New("could not load workflow") + } r := res.(*Workflow) if r.Schedule != nil && r.Schedule.Start == realData.Schedule.Start && r.Schedule.End == realData.Schedule.End && r.Schedule.Cron == realData.Schedule.Cron { return 200, nil