diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2017-02-15 14:01:50 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-02-15 14:01:50 +0800 |
commit | 9d2b830275bf766b9f5e48e3be4b785dc1b2134a (patch) | |
tree | 1b0734e893e41ad48498f935a2ec69d5e0a53066 /routers/home.go | |
parent | 837d34609052b5ea772c4774ef9ed2bf90d5af47 (diff) | |
download | gitea-9d2b830275bf766b9f5e48e3be4b785dc1b2134a.tar.gz gitea-9d2b830275bf766b9f5e48e3be4b785dc1b2134a.zip |
refactor: small optimize for sql query (#940)
* refactor: small optimize for sql query
* fix: get owner name if Searcher is not nil or user star page.
Diffstat (limited to 'routers/home.go')
-rw-r--r-- | routers/home.go | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/routers/home.go b/routers/home.go index 6f211f4f62..3de32b52e7 100644 --- a/routers/home.go +++ b/routers/home.go @@ -6,16 +6,15 @@ package routers import ( "bytes" - "fmt" "strings" - "github.com/Unknwon/paginater" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers/user" + + "github.com/Unknwon/paginater" ) const ( @@ -55,7 +54,7 @@ func Home(ctx *context.Context) { // RepoSearchOptions when calling search repositories type RepoSearchOptions struct { Counter func(bool) int64 - Ranger func(*models.SearchRepoOptions) ([]*models.Repository, error) + Ranger func(*models.SearchRepoOptions) (models.RepositoryList, error) Searcher *models.User Private bool PageSize int @@ -132,13 +131,6 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { ctx.Data["Keyword"] = keyword ctx.Data["Total"] = count ctx.Data["Page"] = paginater.New(int(count), opts.PageSize, page, 5) - - for _, repo := range repos { - if err = repo.GetOwner(); err != nil { - ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", repo.ID, err)) - return - } - } ctx.Data["Repos"] = repos ctx.HTML(200, opts.TplName) |