mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-02-23 03:45:47 -05:00
chore: Remove UsersInTeamsCount
- Introduced in9681c83734
and removed inbac4b78e09
.
This commit is contained in:
parent
d2701877c0
commit
e2dfdcdabd
3 changed files with 0 additions and 26 deletions
|
@ -45,7 +45,6 @@ code.gitea.io/gitea/models/organization
|
|||
GetTeamNamesByID
|
||||
UpdateTeamUnits
|
||||
SearchMembersOptions.ToConds
|
||||
UsersInTeamsCount
|
||||
|
||||
code.gitea.io/gitea/models/perm/access
|
||||
GetRepoWriters
|
||||
|
|
|
@ -188,20 +188,6 @@ func TestHasTeamRepo(t *testing.T) {
|
|||
test(2, 5, false)
|
||||
}
|
||||
|
||||
func TestUsersInTeamsCount(t *testing.T) {
|
||||
require.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
test := func(teamIDs, userIDs []int64, expected int64) {
|
||||
count, err := organization.UsersInTeamsCount(db.DefaultContext, teamIDs, userIDs)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expected, count)
|
||||
}
|
||||
|
||||
test([]int64{2}, []int64{1, 2, 3, 4}, 1) // only userid 2
|
||||
test([]int64{1, 2, 3, 4, 5}, []int64{2, 5}, 2) // userid 2,4
|
||||
test([]int64{1, 2, 3, 4, 5}, []int64{2, 3, 5}, 3) // userid 2,4,5
|
||||
}
|
||||
|
||||
func TestInconsistentOwnerTeam(t *testing.T) {
|
||||
defer unittest.OverrideFixtures(
|
||||
unittest.FixturesOptions{
|
||||
|
|
|
@ -76,14 +76,3 @@ func GetTeamMembers(ctx context.Context, opts *SearchMembersOptions) ([]*user_mo
|
|||
func IsUserInTeams(ctx context.Context, userID int64, teamIDs []int64) (bool, error) {
|
||||
return db.GetEngine(ctx).Where("uid=?", userID).In("team_id", teamIDs).Exist(new(TeamUser))
|
||||
}
|
||||
|
||||
// UsersInTeamsCount counts the number of users which are in userIDs and teamIDs
|
||||
func UsersInTeamsCount(ctx context.Context, userIDs, teamIDs []int64) (int64, error) {
|
||||
var ids []int64
|
||||
if err := db.GetEngine(ctx).In("uid", userIDs).In("team_id", teamIDs).
|
||||
Table("team_user").
|
||||
Cols("uid").GroupBy("uid").Find(&ids); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int64(len(ids)), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue