diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2017-02-04 20:20:20 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-02-04 20:20:20 +0800 |
commit | a90a215662636fed1a2c67b49cf060e2936822f6 (patch) | |
tree | 78ff0fbcb36fb252e671fdbff6011483aca53ce6 /models | |
parent | de81f68d4d4a87c044034be682abffaccd399860 (diff) | |
download | gitea-a90a215662636fed1a2c67b49cf060e2936822f6.tar.gz gitea-a90a215662636fed1a2c67b49cf060e2936822f6.zip |
feat: Add search bar on user profile page. (#787)
Diffstat (limited to 'models')
-rw-r--r-- | models/repo.go | 8 | ||||
-rw-r--r-- | models/user.go | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/models/repo.go b/models/repo.go index 51e8f6351d..3a503d8953 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1579,10 +1579,14 @@ func GetRepositoryByID(id int64) (*Repository, error) { } // GetUserRepositories returns a list of repositories of given user. -func GetUserRepositories(userID int64, private bool, page, pageSize int) ([]*Repository, error) { +func GetUserRepositories(userID int64, private bool, page, pageSize int, orderBy string) ([]*Repository, error) { + if len(orderBy) == 0 { + orderBy = "updated_unix DESC" + } + sess := x. Where("owner_id = ?", userID). - Desc("updated_unix") + OrderBy(orderBy) if !private { sess.And("is_private=?", false) } diff --git a/models/user.go b/models/user.go index c4a1ce3d56..c7ceacaa6b 100644 --- a/models/user.go +++ b/models/user.go @@ -491,7 +491,7 @@ func (u *User) GetOrganizationCount() (int64, error) { // GetRepositories returns repositories that user owns, including private repositories. func (u *User) GetRepositories(page, pageSize int) (err error) { - u.Repos, err = GetUserRepositories(u.ID, true, page, pageSize) + u.Repos, err = GetUserRepositories(u.ID, true, page, pageSize, "") return err } |