From 5d10c3446af946f3f8dcd0874bb7bceb2dcb655c Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 15 Jun 2024 06:48:52 +0200 Subject: [PATCH] rm const do inline (#31360) https://github.com/go-gitea/gitea/pull/30876/files#r1637288202 (cherry picked from commit e37ecd17324946d9b2db07ea10d4a9fbb53da20f) --- models/repo/search.go | 60 +++++++++++++------------------------------ 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/models/repo/search.go b/models/repo/search.go index c500d41be8..2baa85dc6f 100644 --- a/models/repo/search.go +++ b/models/repo/search.go @@ -5,53 +5,29 @@ package repo import "code.gitea.io/gitea/models/db" -// Strings for sorting result -const ( - // only used for repos - SearchOrderByAlphabetically db.SearchOrderBy = "owner_name ASC, name ASC" - SearchOrderByAlphabeticallyReverse db.SearchOrderBy = "owner_name DESC, name DESC" - SearchOrderBySize db.SearchOrderBy = "size ASC" - SearchOrderBySizeReverse db.SearchOrderBy = "size DESC" - SearchOrderByGitSize db.SearchOrderBy = "git_size ASC" - SearchOrderByGitSizeReverse db.SearchOrderBy = "git_size DESC" - SearchOrderByLFSSize db.SearchOrderBy = "lfs_size ASC" - SearchOrderByLFSSizeReverse db.SearchOrderBy = "lfs_size DESC" - // alias as also used elsewhere - SearchOrderByLeastUpdated db.SearchOrderBy = db.SearchOrderByLeastUpdated - SearchOrderByRecentUpdated db.SearchOrderBy = db.SearchOrderByRecentUpdated - SearchOrderByOldest db.SearchOrderBy = db.SearchOrderByOldest - SearchOrderByNewest db.SearchOrderBy = db.SearchOrderByNewest - SearchOrderByID db.SearchOrderBy = db.SearchOrderByID - SearchOrderByIDReverse db.SearchOrderBy = db.SearchOrderByIDReverse - SearchOrderByStars db.SearchOrderBy = db.SearchOrderByStars - SearchOrderByStarsReverse db.SearchOrderBy = db.SearchOrderByStarsReverse - SearchOrderByForks db.SearchOrderBy = db.SearchOrderByForks - SearchOrderByForksReverse db.SearchOrderBy = db.SearchOrderByForksReverse -) - // SearchOrderByMap represents all possible search order var SearchOrderByMap = map[string]map[string]db.SearchOrderBy{ "asc": { - "alpha": SearchOrderByAlphabetically, - "created": SearchOrderByOldest, - "updated": SearchOrderByLeastUpdated, - "size": SearchOrderBySize, - "git_size": SearchOrderByGitSize, - "lfs_size": SearchOrderByLFSSize, - "id": SearchOrderByID, - "stars": SearchOrderByStars, - "forks": SearchOrderByForks, + "alpha": "owner_name ASC, name ASC", + "created": db.SearchOrderByOldest, + "updated": db.SearchOrderByLeastUpdated, + "size": "size ASC", + "git_size": "git_size ASC", + "lfs_size": "lfs_size ASC", + "id": db.SearchOrderByID, + "stars": db.SearchOrderByStars, + "forks": db.SearchOrderByForks, }, "desc": { - "alpha": SearchOrderByAlphabeticallyReverse, - "created": SearchOrderByNewest, - "updated": SearchOrderByRecentUpdated, - "size": SearchOrderBySizeReverse, - "git_size": SearchOrderByGitSizeReverse, - "lfs_size": SearchOrderByLFSSizeReverse, - "id": SearchOrderByIDReverse, - "stars": SearchOrderByStarsReverse, - "forks": SearchOrderByForksReverse, + "alpha": "owner_name DESC, name DESC", + "created": db.SearchOrderByNewest, + "updated": db.SearchOrderByRecentUpdated, + "size": "size DESC", + "git_size": "git_size DESC", + "lfs_size": "lfs_size DESC", + "id": db.SearchOrderByIDReverse, + "stars": db.SearchOrderByStarsReverse, + "forks": db.SearchOrderByForksReverse, }, }