mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 04:34:02 +01:00
optimization for team get repos (#953)
This commit is contained in:
parent
46320f9630
commit
7fd14bf7bd
1 changed files with 2 additions and 16 deletions
|
@ -37,22 +37,8 @@ func (t *Team) IsMember(userID int64) bool {
|
|||
}
|
||||
|
||||
func (t *Team) getRepositories(e Engine) (err error) {
|
||||
teamRepos := make([]*TeamRepo, 0, t.NumRepos)
|
||||
if err = x.
|
||||
Where("team_id=?", t.ID).
|
||||
Find(&teamRepos); err != nil {
|
||||
return fmt.Errorf("get team-repos: %v", err)
|
||||
}
|
||||
|
||||
t.Repos = make([]*Repository, 0, len(teamRepos))
|
||||
for i := range teamRepos {
|
||||
repo, err := getRepositoryByID(e, teamRepos[i].RepoID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("getRepositoryById(%d): %v", teamRepos[i].RepoID, err)
|
||||
}
|
||||
t.Repos = append(t.Repos, repo)
|
||||
}
|
||||
return nil
|
||||
return e.Join("INNER", "team_repo", "repository.id = team_repo.repo_id").
|
||||
Where("team_repo.team_id=?", t.ID).Find(&t.Repos)
|
||||
}
|
||||
|
||||
// GetRepositories returns all repositories in team of organization.
|
||||
|
|
Loading…
Reference in a new issue