diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-04-06 18:47:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-06 18:47:25 -0700 |
commit | 5acfc7c4bc93e547fcb31263da746263d64df7e9 (patch) | |
tree | 5750a669a0e46761df5d234361a17a71b2358317 /models | |
parent | cf6699fb4f845f8f234baa82b556323f022d6788 (diff) | |
download | gitea-5acfc7c4bc93e547fcb31263da746263d64df7e9.tar.gz gitea-5acfc7c4bc93e547fcb31263da746263d64df7e9.zip |
fix migrate failed and org dashboard failed on MSSQL database (#1448)
Diffstat (limited to 'models')
-rw-r--r-- | models/org.go | 25 |
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) } |