state execution
This commit is contained in:
@@ -52,7 +52,7 @@ func (wfa *bookingMongoAccessor) LoadOne(id string) (utils.DBObject, int, error)
|
||||
return &workflow, 200, nil
|
||||
}
|
||||
|
||||
func (wfa bookingMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
|
||||
func (wfa *bookingMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
|
||||
objs := []utils.ShallowDBObject{}
|
||||
res_mongo, code, err := mongo.MONGOService.LoadAll(wfa.GetType())
|
||||
if err != nil {
|
||||
@@ -64,6 +64,10 @@ func (wfa bookingMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error)
|
||||
return nil, 404, err
|
||||
}
|
||||
for _, r := range results {
|
||||
if r.State == workflow_execution.SCHEDULED && time.Now().UTC().After(*r.ExecDate) {
|
||||
r.State = workflow_execution.FORGOTTEN
|
||||
wfa.GenericRawUpdateOne(&r, r.UUID, wfa)
|
||||
}
|
||||
objs = append(objs, &r.AbstractObject) // Warning only AbstractObject is returned
|
||||
}
|
||||
return objs, 200, nil
|
||||
@@ -89,6 +93,10 @@ func (wfa *bookingMongoAccessor) Search(filters *dbs.Filters, search string) ([]
|
||||
return nil, 404, err
|
||||
}
|
||||
for _, r := range results {
|
||||
if r.State == workflow_execution.SCHEDULED && time.Now().UTC().After(*r.ExecDate) {
|
||||
r.State = workflow_execution.FORGOTTEN
|
||||
wfa.GenericRawUpdateOne(&r, r.UUID, wfa)
|
||||
}
|
||||
objs = append(objs, &r)
|
||||
}
|
||||
return objs, 200, nil
|
||||
|
Reference in New Issue
Block a user