simplify call to peer

This commit is contained in:
mr 2024-08-26 17:59:58 +02:00
parent 767c14044f
commit 463144a062

View File

@ -215,7 +215,7 @@ func (wfa *sharedWorkspaceMongoAccessor) enrich(sharedWorkspace *SharedWorkspace
access = (&w.Workflow{}).GetAccessor(nil) access = (&w.Workflow{}).GetAccessor(nil)
res, code, _ = access.Search(&dbs.Filters{ res, code, _ = access.Search(&dbs.Filters{
Or: map[string][]dbs.Filter{ Or: map[string][]dbs.Filter{
"abstractobject.id": {{Operator: dbs.IN.String(), Value: sharedWorkspace.Workspaces}}, "abstractobject.id": {{Operator: dbs.IN.String(), Value: sharedWorkspace.Workflows}},
}, },
}, "") }, "")
if code == 200 { if code == 200 {
@ -249,15 +249,14 @@ func (wfa *sharedWorkspaceMongoAccessor) enrich(sharedWorkspace *SharedWorkspace
} }
func (wfa *sharedWorkspaceMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) { func (wfa *sharedWorkspaceMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
var sharedWorkspace *SharedWorkspace var sharedWorkspace SharedWorkspace
res_mongo, code, err := mongo.MONGOService.LoadOne(id, wfa.GetType()) res_mongo, code, err := mongo.MONGOService.LoadOne(id, wfa.GetType())
if err != nil { if err != nil {
wfa.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error()) wfa.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return nil, code, err return nil, code, err
} }
res_mongo.Decode(sharedWorkspace) res_mongo.Decode(&sharedWorkspace)
sharedWorkspace = wfa.enrich(sharedWorkspace) return wfa.enrich(&sharedWorkspace), 200, nil
return sharedWorkspace, 200, nil
} }
func (wfa sharedWorkspaceMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) { func (wfa sharedWorkspaceMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
@ -272,9 +271,7 @@ func (wfa sharedWorkspaceMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int,
return nil, 404, err return nil, 404, err
} }
for _, r := range results { for _, r := range results {
r2 := &r objs = append(objs, wfa.enrich(&r))
r2 = wfa.enrich(r2)
objs = append(objs, r2)
} }
return objs, 200, nil return objs, 200, nil
} }
@ -298,9 +295,7 @@ func (wfa *sharedWorkspaceMongoAccessor) Search(filters *dbs.Filters, search str
return nil, 404, err return nil, 404, err
} }
for _, r := range results { for _, r := range results {
r2 := &r objs = append(objs, wfa.enrich(&r))
r2 = wfa.enrich(r2)
objs = append(objs, r2)
} }
return objs, 200, nil return objs, 200, nil
} }