From aafcb0bac42974c378e4fee6f0640cbcd5989f28 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 27 Mar 2023 12:02:35 +0200 Subject: [PATCH] fix(projects): don't return child projects twice --- pkg/models/project.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/models/project.go b/pkg/models/project.go index 100e23beae8..7a8b324c314 100644 --- a/pkg/models/project.go +++ b/pkg/models/project.go @@ -220,6 +220,7 @@ func (p *Project) ReadAll(s *xorm.Session, a web.Auth, search string, page int, ////////////////////////// // Putting it all together + projectsResult := []*Project{} for _, p := range allProjects { if p.ParentProjectID != 0 { if allProjects[p.ParentProjectID].ChildProjects == nil { @@ -229,11 +230,13 @@ func (p *Project) ReadAll(s *xorm.Session, a web.Auth, search string, page int, continue } + projectsResult = append(projectsResult, p) + // The projects variable will contain all projects which have no parents // And because we're using the same pointers for everything, those will contain child projects } - return prs, resultCount, totalItems, err + return projectsResult, resultCount, totalItems, err } // ReadOne gets one project by its ID