From 78e8296e113e2fd9259ec05fe87035427821ea0b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 15 Jun 2024 08:45:02 +0200 Subject: [PATCH] Rename repo_model.SearchOrderByMap to repo_model.OrderByMap (#31359) https://github.com/go-gitea/gitea/pull/30876#discussion_r1637112394 --- models/repo/search.go | 38 ++++++++++++++++++------------------- routers/api/v1/repo/repo.go | 2 +- routers/web/explore/repo.go | 2 +- routers/web/repo/repo.go | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/models/repo/search.go b/models/repo/search.go index 2baa85dc6f2..a73d9fc2153 100644 --- a/models/repo/search.go +++ b/models/repo/search.go @@ -5,8 +5,8 @@ package repo import "code.gitea.io/gitea/models/db" -// SearchOrderByMap represents all possible search order -var SearchOrderByMap = map[string]map[string]db.SearchOrderBy{ +// OrderByMap represents all possible search order +var OrderByMap = map[string]map[string]db.SearchOrderBy{ "asc": { "alpha": "owner_name ASC, name ASC", "created": db.SearchOrderByOldest, @@ -31,22 +31,22 @@ var SearchOrderByMap = map[string]map[string]db.SearchOrderBy{ }, } -// SearchOrderByFlatMap is similar to SearchOrderByMap but use human language keywords +// OrderByFlatMap is similar to OrderByMap but use human language keywords // to decide between asc and desc -var SearchOrderByFlatMap = map[string]db.SearchOrderBy{ - "newest": SearchOrderByMap["desc"]["created"], - "oldest": SearchOrderByMap["asc"]["created"], - "leastupdate": SearchOrderByMap["asc"]["updated"], - "reversealphabetically": SearchOrderByMap["desc"]["alpha"], - "alphabetically": SearchOrderByMap["asc"]["alpha"], - "reversesize": SearchOrderByMap["desc"]["size"], - "size": SearchOrderByMap["asc"]["size"], - "reversegitsize": SearchOrderByMap["desc"]["git_size"], - "gitsize": SearchOrderByMap["asc"]["git_size"], - "reverselfssize": SearchOrderByMap["desc"]["lfs_size"], - "lfssize": SearchOrderByMap["asc"]["lfs_size"], - "moststars": SearchOrderByMap["desc"]["stars"], - "feweststars": SearchOrderByMap["asc"]["stars"], - "mostforks": SearchOrderByMap["desc"]["forks"], - "fewestforks": SearchOrderByMap["asc"]["forks"], +var OrderByFlatMap = map[string]db.SearchOrderBy{ + "newest": OrderByMap["desc"]["created"], + "oldest": OrderByMap["asc"]["created"], + "leastupdate": OrderByMap["asc"]["updated"], + "reversealphabetically": OrderByMap["desc"]["alpha"], + "alphabetically": OrderByMap["asc"]["alpha"], + "reversesize": OrderByMap["desc"]["size"], + "size": OrderByMap["asc"]["size"], + "reversegitsize": OrderByMap["desc"]["git_size"], + "gitsize": OrderByMap["asc"]["git_size"], + "reverselfssize": OrderByMap["desc"]["lfs_size"], + "lfssize": OrderByMap["asc"]["lfs_size"], + "moststars": OrderByMap["desc"]["stars"], + "feweststars": OrderByMap["asc"]["stars"], + "mostforks": OrderByMap["desc"]["forks"], + "fewestforks": OrderByMap["asc"]["forks"], } diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 9ba58875254..4f617d27afa 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -184,7 +184,7 @@ func Search(ctx *context.APIContext) { if len(sortOrder) == 0 { sortOrder = "asc" } - if searchModeMap, ok := repo_model.SearchOrderByMap[sortOrder]; ok { + if searchModeMap, ok := repo_model.OrderByMap[sortOrder]; ok { if orderBy, ok := searchModeMap[sortMode]; ok { opts.OrderBy = orderBy } else { diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index 22b1fc5bf9d..1d17f962f25 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -63,7 +63,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { sortOrder = setting.UI.ExploreDefaultSort } - if order, ok := repo_model.SearchOrderByFlatMap[sortOrder]; ok { + if order, ok := repo_model.OrderByFlatMap[sortOrder]; ok { orderBy = order } else { sortOrder = "recentupdate" diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 514a5ab02cd..92f74bbf333 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -616,7 +616,7 @@ func SearchRepo(ctx *context.Context) { if len(sortOrder) == 0 { sortOrder = "asc" } - if searchModeMap, ok := repo_model.SearchOrderByMap[sortOrder]; ok { + if searchModeMap, ok := repo_model.OrderByMap[sortOrder]; ok { if orderBy, ok := searchModeMap[sortMode]; ok { opts.OrderBy = orderBy } else {