This commit is contained in:
mr 2024-11-21 07:51:59 +01:00
parent ac49d3324d
commit d8fac883d2

View File

@ -348,14 +348,18 @@ func (wfa *workflowMongoAccessor) LoadOne(id string) (utils.DBObject, int, error
return nil, code, err return nil, code, err
} }
res_mongo.Decode(&workflow) res_mongo.Decode(&workflow)
found := false
if workflow.ScheduleActive && workflow.Schedule != nil { // if the workflow is scheduled, update the executions if workflow.ScheduleActive && workflow.Schedule != nil { // if the workflow is scheduled, update the executions
now := time.Now().UTC() now := time.Now().UTC()
if (workflow.Schedule.End != nil && now.After(*workflow.Schedule.End)) || (workflow.Schedule.End == nil && workflow.Schedule.Start != nil && now.After(*workflow.Schedule.Start)) { // if the start date is passed, then you can book if (workflow.Schedule.End != nil && now.After(*workflow.Schedule.End)) || (workflow.Schedule.End == nil && workflow.Schedule.Start != nil && now.After(*workflow.Schedule.Start)) { // if the start date is passed, then you can book
workflow.ScheduleActive = false workflow.ScheduleActive = false
wfa.GenericRawUpdateOne(&workflow, id, wfa) found = true
} // if the start date is passed, update the executions } // if the start date is passed, update the executions
} }
wfa.execute(&workflow, false, true) // if no workspace is attached to the workflow, create it wfa.execute(&workflow, false, true) // if no workspace is attached to the workflow, create it
if found {
wfa.GenericRawUpdateOne(&workflow, id, wfa)
}
return &workflow, 200, nil return &workflow, 200, nil
} }