From 463144a0625bfbba8e58d0078bed386f9a03c3b2 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 26 Aug 2024 17:59:58 +0200 Subject: [PATCH] simplify call to peer --- .../shared/shared_workspace_mongo_accessor.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/models/workspace/shared/shared_workspace_mongo_accessor.go b/models/workspace/shared/shared_workspace_mongo_accessor.go index 4dfaedc..150285d 100644 --- a/models/workspace/shared/shared_workspace_mongo_accessor.go +++ b/models/workspace/shared/shared_workspace_mongo_accessor.go @@ -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 }