debug automation workspace

This commit is contained in:
mr 2024-07-31 09:52:57 +02:00
parent 511e0c3f31
commit d6a2a416c1

View File

@ -53,15 +53,7 @@ func (wfa *WorkspaceMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject,
return wfa.GenericStoreOne(data, wfa)
}
func (wfa *WorkspaceMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
var workflow Workspace
res_mongo, code, err := mongo.MONGOService.LoadOne(id, wfa.GetType())
if err != nil {
wfa.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return nil, code, err
}
res_mongo.Decode(&workflow)
func (wfa *WorkspaceMongoAccessor) fill(workflow *Workspace) *Workspace {
if workflow.Datas != nil && len(workflow.Datas) > 0 {
dataAccessor := (&data.DataResource{}).GetAccessor()
for _, id := range workflow.Datas {
@ -107,7 +99,19 @@ func (wfa *WorkspaceMongoAccessor) LoadOne(id string) (utils.DBObject, int, erro
}
}
}
return &workflow, 200, nil
return workflow
}
func (wfa *WorkspaceMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
var workflow Workspace
res_mongo, code, err := mongo.MONGOService.LoadOne(id, wfa.GetType())
if err != nil {
wfa.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return nil, code, err
}
res_mongo.Decode(&workflow)
return wfa.fill(&workflow), 200, nil
}
func (wfa WorkspaceMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
@ -122,7 +126,7 @@ func (wfa WorkspaceMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r)
objs = append(objs, wfa.fill(&r))
}
return objs, 200, nil
}
@ -139,7 +143,7 @@ func (wfa *WorkspaceMongoAccessor) Search(word string) ([]utils.ShallowDBObject,
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r)
objs = append(objs, wfa.fill(&r))
}
return objs, 200, nil
}