mongo and or

This commit is contained in:
mr 2024-08-02 16:45:45 +02:00
parent 51541010e2
commit caf0c1afcb

View File

@ -25,7 +25,15 @@ func (wfa *workflowMongoAccessor) DeleteOne(id string) (utils.DBObject, int, err
return wfa.GenericDeleteOne(id, wfa)
}
func (wfa *workflowMongoAccessor) execution(realData *Workflow, delete bool) (int, error) {
func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delete bool) (int, error) {
if realData.Schedule == nil {
return 200, nil
}
res, _, _ := wfa.LoadOne(id)
r := res.(*Workflow)
if r.Schedule.Start == realData.Schedule.Start && r.Schedule.End == realData.Schedule.End && r.Schedule.Cron == realData.Schedule.Cron {
return 200, nil
}
if delete {
mongo.MONGOService.DeleteMultiple(map[string]interface{}{
"workflow_id": realData.UUID,
@ -71,7 +79,7 @@ func (wfa *workflowMongoAccessor) execution(realData *Workflow, delete bool) (in
}
func (wfa *workflowMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
if code, err := wfa.execution(set.(*Workflow), true); err != nil {
if code, err := wfa.execution(id, set.(*Workflow), true); err != nil {
return nil, code, err
}
res, code, err := wfa.GenericUpdateOne(set, id, wfa, &Workflow{})
@ -87,7 +95,7 @@ func (wfa *workflowMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject,
if err != nil {
return nil, code, err
}
if code, err := wfa.execution(res.(*Workflow), false); err != nil {
if code, err := wfa.execution(res.GetID(), res.(*Workflow), false); err != nil {
return nil, code, err
}
wfa.execute(res.(*Workflow))