From eaee8f07b1230f63f6133aaad40ee608c0d2080b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Sat, 19 Jul 2025 23:09:44 -0400 Subject: [PATCH] fix duplicate teams being returned by `GetTeamsWithAccessToGroup` --- models/organization/team_group.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/organization/team_group.go b/models/organization/team_group.go index 95b1d6d983..0cdaa742e6 100644 --- a/models/organization/team_group.go +++ b/models/organization/team_group.go @@ -11,8 +11,8 @@ import ( func GetTeamsWithAccessToGroup(ctx context.Context, orgID, groupID int64, mode perm.AccessMode) ([]*Team, error) { teams := make([]*Team, 0) inCond := group_model.ParentGroupCond("group_team.group_id", groupID) - return teams, db.GetEngine(ctx).Where("group_team.access_mode >= ?", mode). - Join("INNER", "group_team", "group_team.team_id = team.id"). + return teams, db.GetEngine(ctx).Distinct("team.*").Where("group_team.access_mode >= ?", mode). + Join("INNER", "group_team", "group_team.team_id = team.id and group_team.org_id = ?", orgID). And("group_team.org_id = ?", orgID). And(inCond). OrderBy("name").