summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/org.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/models/org.go b/models/org.go
index 9d7aaec7ef..fb07c4aaf2 100644
--- a/models/org.go
+++ b/models/org.go
@@ -670,13 +670,30 @@ func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*Repository, error)
Find(&repos)
}
-func (env *accessibleReposEnv) MirrorRepos() ([]*Repository, error) {
- repos := make([]*Repository, 0, 10)
- return repos, x.
- Select("`repository`.*").
+func (env *accessibleReposEnv) MirrorRepoIDs() ([]int64, error) {
+ repoIDs := make([]int64, 0, 10)
+ return repoIDs, x.
+ Table("repository").
Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id AND `repository`.is_mirror=?", true).
Where(env.cond()).
GroupBy("`repository`.id").
OrderBy("updated_unix DESC").
+ Cols("`repository`.id").
+ Find(&repoIDs)
+}
+
+func (env *accessibleReposEnv) MirrorRepos() ([]*Repository, error) {
+ repoIDs, err := env.MirrorRepoIDs()
+ if err != nil {
+ return nil, fmt.Errorf("MirrorRepoIDs: %v", err)
+ }
+
+ repos := make([]*Repository, 0, len(repoIDs))
+ if len(repoIDs) <= 0 {
+ return repos, nil
+ }
+
+ return repos, x.
+ In("`repository`.id", repoIDs).
Find(&repos)
}