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 /models/star.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 'models/star.go')
-rw-r--r-- | models/star.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/models/star.go b/models/star.go index 7525c8a6fa..96f876ba0a 100644 --- a/models/star.go +++ b/models/star.go @@ -71,7 +71,7 @@ func (repo *Repository) GetStargazers(page int) ([]*User, error) { } // GetStarredRepos returns the repos the user starred. -func (u *User) GetStarredRepos(private bool, page, pageSize int, orderBy string) (repos []*Repository, err error) { +func (u *User) GetStarredRepos(private bool, page, pageSize int, orderBy string) (repos RepositoryList, err error) { if len(orderBy) == 0 { orderBy = "updated_unix DESC" } @@ -95,10 +95,8 @@ func (u *User) GetStarredRepos(private bool, page, pageSize int, orderBy string) return } - for _, repo := range repos { - if err = repo.GetOwner(); err != nil { - return - } + if err = repos.loadAttributes(x); err != nil { + return } return |