Skip to content

Commit bf82bdb

Browse files
committed
Merge branch master into indexbyfileext
2 parents e48f041 + 714dcf9 commit bf82bdb

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ BINDATA := modules/{options,public,templates}/bindata.go
2222
GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go")
2323
GOFMT ?= gofmt -s
2424

25-
GOFLAGS := -i -v
25+
GOFLAGS := -v
2626
EXTRA_GOFLAGS ?=
2727

2828
MAKE_VERSION := $(shell make -v | head -n 1)

models/org_team.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,14 @@ func IsUserInTeams(userID int64, teamIDs []int64) (bool, error) {
760760
}
761761

762762
// UsersInTeamsCount counts the number of users which are in userIDs and teamIDs
763-
func UsersInTeamsCount(userIDs []int64, teamIDs []int64) (count int64, err error) {
764-
if count, err = x.In("uid", userIDs).In("team_id", teamIDs).Count(new(TeamUser)); err != nil {
763+
func UsersInTeamsCount(userIDs []int64, teamIDs []int64) (int64, error) {
764+
var ids []int64
765+
if err := x.In("uid", userIDs).In("team_id", teamIDs).
766+
Table("team_user").
767+
Cols("uid").GroupBy("uid").Find(&ids); err != nil {
765768
return 0, err
766769
}
767-
return
770+
return int64(len(ids)), nil
768771
}
769772

770773
// ___________ __________

models/org_team_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func TestUsersInTeamsCount(t *testing.T) {
370370
assert.Equal(t, expected, count)
371371
}
372372

373-
test([]int64{2}, []int64{1, 2, 3, 4}, 2)
374-
test([]int64{1, 2, 3, 4, 5}, []int64{2, 5}, 2)
375-
test([]int64{1, 2, 3, 4, 5}, []int64{2, 3, 5}, 3)
373+
test([]int64{2}, []int64{1, 2, 3, 4}, 1) // only userid 2
374+
test([]int64{1, 2, 3, 4, 5}, []int64{2, 5}, 2) // userid 2,4
375+
test([]int64{1, 2, 3, 4, 5}, []int64{2, 3, 5}, 3) // userid 2,4,5
376376
}

0 commit comments

Comments
 (0)