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)
res, code, _ = access.Search(&dbs.Filters{
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 {
@ -249,15 +249,14 @@ func (wfa *sharedWorkspaceMongoAccessor) enrich(sharedWorkspace *SharedWorkspace
}
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())
if err != nil {
wfa.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return nil, code, err
}
res_mongo.Decode(sharedWorkspace)
sharedWorkspace = wfa.enrich(sharedWorkspace)
return sharedWorkspace, 200, nil
res_mongo.Decode(&sharedWorkspace)
return wfa.enrich(&sharedWorkspace), 200, nil
}
func (wfa sharedWorkspaceMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
@ -272,9 +271,7 @@ func (wfa sharedWorkspaceMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int,
return nil, 404, err
}
for _, r := range results {
r2 := &r
r2 = wfa.enrich(r2)
objs = append(objs, r2)
objs = append(objs, wfa.enrich(&r))
}
return objs, 200, nil
}
@ -298,9 +295,7 @@ func (wfa *sharedWorkspaceMongoAccessor) Search(filters *dbs.Filters, search str
return nil, 404, err
}
for _, r := range results {
r2 := &r
r2 = wfa.enrich(r2)
objs = append(objs, r2)
objs = append(objs, wfa.enrich(&r))
}
return objs, 200, nil
}