summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2017-02-04 20:20:20 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-04 20:20:20 +0800
commita90a215662636fed1a2c67b49cf060e2936822f6 (patch)
tree78ff0fbcb36fb252e671fdbff6011483aca53ce6 /models
parentde81f68d4d4a87c044034be682abffaccd399860 (diff)
downloadgitea-a90a215662636fed1a2c67b49cf060e2936822f6.tar.gz
gitea-a90a215662636fed1a2c67b49cf060e2936822f6.zip
feat: Add search bar on user profile page. (#787)
Diffstat (limited to 'models')
-rw-r--r--models/repo.go8
-rw-r--r--models/user.go2
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
}