diff options
Diffstat (limited to 'models/org_team.go')
-rw-r--r-- | models/org_team.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/models/org_team.go b/models/org_team.go index 1786376d02..799716679c 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -760,11 +760,14 @@ func IsUserInTeams(userID int64, teamIDs []int64) (bool, error) { } // UsersInTeamsCount counts the number of users which are in userIDs and teamIDs -func UsersInTeamsCount(userIDs []int64, teamIDs []int64) (count int64, err error) { - if count, err = x.In("uid", userIDs).In("team_id", teamIDs).Count(new(TeamUser)); err != nil { +func UsersInTeamsCount(userIDs []int64, teamIDs []int64) (int64, error) { + var ids []int64 + if err := x.In("uid", userIDs).In("team_id", teamIDs). + Table("team_user"). + Cols("uid").GroupBy("uid").Find(&ids); err != nil { return 0, err } - return + return int64(len(ids)), nil } // ___________ __________ |