diff options
author | Alexey Terentyev <terentyev.alexey@gmail.com> | 2018-05-24 04:03:42 +0300 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2018-05-24 09:03:42 +0800 |
commit | b908ac9fab141b72f38db3d40a9f6054bb701982 (patch) | |
tree | 11a91f0a12fa32b0fa834d0388949fb59d13f4a2 /models | |
parent | ea2a938e8a25588634364b3bc6ce8d6634ae4c60 (diff) | |
download | gitea-b908ac9fab141b72f38db3d40a9f6054bb701982.tar.gz gitea-b908ac9fab141b72f38db3d40a9f6054bb701982.zip |
Added repository search ordered by stars or forks. Forks column in admin repo list. (#3969)
* Added repository search order by stars or forks.
Added Forks column to admin repository list.
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
* Renamed search repo template
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
Diffstat (limited to 'models')
-rw-r--r-- | models/repo_list.go | 4 | ||||
-rw-r--r-- | models/user.go | 4 |
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) } |