From 6c98052176c52f390f878c80323185d8050ab293 Mon Sep 17 00:00:00 2001 From: waza-ari Date: Sun, 10 Mar 2024 21:42:34 +0000 Subject: [PATCH] fix(teams): fix duplicate teams being shown when new public team visibility feature is enabled (#2187) Due to the `INNER JOIN` on the `team_members` table and the new `OR` conditions allowing teams with the `isPublic` flag set to `true`, teams are returned multiple times. As we're only after the teams, a simple distinct query should fix the issue. Co-authored-by: Daniel Herrmann Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/2187 Co-authored-by: waza-ari Co-committed-by: waza-ari --- pkg/models/teams.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/models/teams.go b/pkg/models/teams.go index 8cae52324..2c911b42e 100644 --- a/pkg/models/teams.go +++ b/pkg/models/teams.go @@ -296,7 +296,7 @@ func (t *Team) ReadAll(s *xorm.Session, a web.Auth, search string, page int, per limit, start := getLimitFromPageIndex(page, perPage) all := []*Team{} - query := s.Select("teams.*"). + query := s.Distinct("teams.*"). Table("teams"). Join("INNER", "team_members", "team_members.team_id = teams.id"). Where(db.ILIKE("teams.name", search))