discovery is bugged
This commit is contained in:
parent
94803f820a
commit
08e9ee67fe
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
||||||
@ -247,14 +248,21 @@ func (wfa *workflowMongoAccessor) UpdateOne(set utils.DBObject, id string) (util
|
|||||||
if code != 200 {
|
if code != 200 {
|
||||||
return nil, code, err
|
return nil, code, err
|
||||||
}
|
}
|
||||||
fmt.Println("UPDATE", avoid, res.(*Workflow).ScheduleActive)
|
workflow := res.(*Workflow)
|
||||||
|
if workflow.ScheduleActive && workflow.Schedule != nil { // if the workflow is scheduled, update the executions
|
||||||
|
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
|
||||||
|
workflow.ScheduleActive = false
|
||||||
|
wfa.UpdateOne(workflow, id)
|
||||||
|
} // if the start date is passed, update the executions
|
||||||
|
}
|
||||||
if !avoid { // if the schedule is not avoided, update the executions
|
if !avoid { // if the schedule is not avoided, update the executions
|
||||||
if code, err := wfa.execution(id, res.(*Workflow), false); code != 200 {
|
if code, err := wfa.execution(id, workflow, false); code != 200 {
|
||||||
return nil, code, errors.New("could not update the executions : " + err.Error())
|
return nil, code, errors.New("could not update the executions : " + err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wfa.execute(res.(*Workflow), false, false) // update the workspace for the workflow
|
wfa.execute(workflow, false, false) // update the workspace for the workflow
|
||||||
wfa.share(res.(*Workflow), false, wfa.Caller) // share the update to the peers
|
wfa.share(workflow, false, wfa.Caller) // share the update to the peers
|
||||||
return res, code, nil
|
return res, code, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,12 +272,20 @@ func (wfa *workflowMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject,
|
|||||||
if err != nil || code != 200 {
|
if err != nil || code != 200 {
|
||||||
return nil, code, err
|
return nil, code, err
|
||||||
}
|
}
|
||||||
wfa.share(res.(*Workflow), false, wfa.Caller) // share the creation to the peers
|
workflow := res.(*Workflow)
|
||||||
|
if workflow.ScheduleActive && workflow.Schedule != nil { // if the workflow is scheduled, update the executions
|
||||||
|
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
|
||||||
|
workflow.ScheduleActive = false
|
||||||
|
wfa.UpdateOne(workflow, workflow.UUID)
|
||||||
|
} // if the start date is passed, update the executions
|
||||||
|
}
|
||||||
|
wfa.share(workflow, false, wfa.Caller) // share the creation to the peers
|
||||||
//store the executions
|
//store the executions
|
||||||
if code, err := wfa.execution(res.GetID(), res.(*Workflow), false); err != nil {
|
if code, err := wfa.execution(res.GetID(), workflow, false); err != nil {
|
||||||
return nil, code, err
|
return nil, code, err
|
||||||
}
|
}
|
||||||
wfa.execute(res.(*Workflow), false, false) // store the workspace for the workflow
|
wfa.execute(workflow, false, false) // store the workspace for the workflow
|
||||||
return res, code, nil
|
return res, code, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,8 +346,14 @@ 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)
|
||||||
|
if workflow.ScheduleActive && workflow.Schedule != nil { // if the workflow is scheduled, update the executions
|
||||||
|
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
|
||||||
|
workflow.ScheduleActive = false
|
||||||
|
wfa.UpdateOne(&workflow, id)
|
||||||
|
} // 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
|
||||||
|
|
||||||
return &workflow, 200, nil
|
return &workflow, 200, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user