return nil
}
- org, err := GetUserByID(orgID)
+ org, err := getUserByID(sess, orgID)
if err != nil {
return fmt.Errorf("GetUserByID [%d]: %v", orgID, err)
}
// Check if the user to delete is the last member in owner team.
- if isOwner, err := IsOrganizationOwner(orgID, userID); err != nil {
+ if isOwner, err := isOrganizationOwner(sess, orgID, userID); err != nil {
return err
} else if isOwner {
- t, err := org.GetOwnerTeam()
+ t, err := org.getOwnerTeam(sess)
if err != nil {
return err
}
if t.NumMembers == 1 {
- if err := t.GetMembers(); err != nil {
+ if err := t.getMembers(sess); err != nil {
return err
}
if t.Members[0].ID == userID {
}
// Delete all repository accesses and unwatch them.
- env, err := org.AccessibleReposEnv(userID)
+ env, err := org.accessibleReposEnv(sess, userID)
if err != nil {
return fmt.Errorf("AccessibleReposEnv: %v", err)
}
org *User
userID int64
teamIDs []int64
+ e Engine
}
// AccessibleReposEnv an AccessibleReposEnvironment for the repositories in `org`
// that are accessible to the specified user.
func (org *User) AccessibleReposEnv(userID int64) (AccessibleReposEnvironment, error) {
- teamIDs, err := org.GetUserTeamIDs(userID)
+ return org.accessibleReposEnv(x, userID)
+}
+
+func (org *User) accessibleReposEnv(e Engine, userID int64) (AccessibleReposEnvironment, error) {
+ teamIDs, err := org.getUserTeamIDs(e, userID)
if err != nil {
return nil, err
}
- return &accessibleReposEnv{org: org, userID: userID, teamIDs: teamIDs}, nil
+ return &accessibleReposEnv{
+ org: org,
+ userID: userID,
+ teamIDs: teamIDs,
+ e: e,
+ }, nil
}
func (env *accessibleReposEnv) cond() builder.Cond {
}
func (env *accessibleReposEnv) CountRepos() (int64, error) {
- repoCount, err := x.
+ repoCount, err := env.e.
Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id").
Where(env.cond()).
Distinct("`repository`.id").
}
repoIDs := make([]int64, 0, pageSize)
- return repoIDs, x.
+ return repoIDs, env.e.
Table("repository").
Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id").
Where(env.cond()).
return repos, nil
}
- return repos, x.
+ return repos, env.e.
In("`repository`.id", repoIDs).
Find(&repos)
}
func (env *accessibleReposEnv) MirrorRepoIDs() ([]int64, error) {
repoIDs := make([]int64, 0, 10)
- return repoIDs, x.
+ return repoIDs, env.e.
Table("repository").
Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id AND `repository`.is_mirror=?", true).
Where(env.cond()).
return repos, nil
}
- return repos, x.
+ return repos, env.e.
In("`repository`.id", repoIDs).
Find(&repos)
}