fix(teams): fix duplicate teams being shown when new public team visibility feature is enabled (#2187)
continuous-integration/drone/push Build is passing Details

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 <daniel.herrmann1@gmail.com>
Reviewed-on: #2187
Co-authored-by: waza-ari <daniel.herrmann@makerspace-darmstadt.de>
Co-committed-by: waza-ari <daniel.herrmann@makerspace-darmstadt.de>
This commit is contained in:
waza-ari 2024-03-10 21:42:34 +00:00 committed by konrad
parent 0057ac5836
commit 6c98052176
1 changed files with 1 additions and 1 deletions

View File

@ -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))