diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2016-11-12 01:31:37 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2016-11-12 01:31:37 +0800 |
commit | ade6d4a20fed2f84cf98830c9691b826254bd31f (patch) | |
tree | 9ea141aebcf154ab6a1945d1f6d36bfdaca9857b /models/org.go | |
parent | 9bf28a2799f080a12c6eb85aa2fb9d4deacc37fc (diff) | |
download | gitea-ade6d4a20fed2f84cf98830c9691b826254bd31f.tar.gz gitea-ade6d4a20fed2f84cf98830c9691b826254bd31f.zip |
optimization on database IN
Diffstat (limited to 'models/org.go')
-rw-r--r-- | models/org.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/models/org.go b/models/org.go index 1caf241eaa..7b251b2020 100644 --- a/models/org.go +++ b/models/org.go @@ -10,9 +10,8 @@ import ( "os" "strings" + "github.com/go-xorm/builder" "github.com/go-xorm/xorm" - - "code.gitea.io/gitea/modules/base" ) var ( @@ -540,7 +539,7 @@ func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repos Select("`repository`.*"). Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id"). Where("(`repository`.owner_id=? AND `repository`.is_private=?)", org.ID, false). - Or("team_repo.team_id IN (?)", strings.Join(base.Int64sToStrings(teamIDs), ",")). + Or(builder.In("team_repo.team_id", teamIDs)). GroupBy("`repository`.id"). OrderBy("updated_unix DESC"). Limit(pageSize, (page-1)*pageSize). @@ -551,7 +550,7 @@ func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repos repoCount, err := x. Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id"). Where("(`repository`.owner_id=? AND `repository`.is_private=?)", org.ID, false). - Or("team_repo.team_id IN (?)", strings.Join(base.Int64sToStrings(teamIDs), ",")). + Or(builder.In("team_repo.team_id", teamIDs)). GroupBy("`repository`.id"). Count(&Repository{}) if err != nil { @@ -577,7 +576,7 @@ func (org *User) GetUserMirrorRepositories(userID int64) ([]*Repository, error) Select("`repository`.*"). Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id AND `repository`.is_mirror=?", true). Where("(`repository`.owner_id=? AND `repository`.is_private=?)", org.ID, false). - Or("team_repo.team_id IN (?)", strings.Join(base.Int64sToStrings(teamIDs), ",")). + Or(builder.In("team_repo.team_id", teamIDs)). GroupBy("`repository`.id"). OrderBy("updated_unix DESC"). Find(&repos) |