summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/repo_list.go4
-rw-r--r--models/user.go4
2 files changed, 6 insertions, 2 deletions
diff --git a/models/repo_list.go b/models/repo_list.go
index df6b81cb8d..b1527b73c9 100644
--- a/models/repo_list.go
+++ b/models/repo_list.go
@@ -152,6 +152,10 @@ const (
SearchOrderBySizeReverse = "size DESC"
SearchOrderByID = "id ASC"
SearchOrderByIDReverse = "id DESC"
+ SearchOrderByStars = "num_stars ASC"
+ SearchOrderByStarsReverse = "num_stars DESC"
+ SearchOrderByForks = "num_forks ASC"
+ SearchOrderByForksReverse = "num_forks DESC"
)
// SearchRepositoryByName takes keyword and part of repository name to search,
diff --git a/models/user.go b/models/user.go
index 8f5ee6e5a7..d642054979 100644
--- a/models/user.go
+++ b/models/user.go
@@ -1272,7 +1272,7 @@ func GetUser(user *User) (bool, error) {
type SearchUserOptions struct {
Keyword string
Type UserType
- OrderBy string
+ OrderBy SearchOrderBy
Page int
PageSize int // Can be smaller than or equal to setting.UI.ExplorePagingNum
IsActive util.OptionalBool
@@ -1322,7 +1322,7 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) {
users = make([]*User, 0, opts.PageSize)
return users, count, x.Where(cond).
Limit(opts.PageSize, (opts.Page-1)*opts.PageSize).
- OrderBy(opts.OrderBy).
+ OrderBy(opts.OrderBy.String()).
Find(&users)
}