2023-05-08 17:36:54 +08:00
|
|
|
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package repo
|
|
|
|
|
|
|
|
import "code.gitea.io/gitea/models/db"
|
|
|
|
|
|
|
|
// SearchOrderByMap represents all possible search order
|
|
|
|
var SearchOrderByMap = map[string]map[string]db.SearchOrderBy{
|
|
|
|
"asc": {
|
2024-06-15 12:48:52 +08:00
|
|
|
"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,
|
2023-05-08 17:36:54 +08:00
|
|
|
},
|
|
|
|
"desc": {
|
2024-06-15 12:48:52 +08:00
|
|
|
"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,
|
2023-05-08 17:36:54 +08:00
|
|
|
},
|
|
|
|
}
|
2024-06-13 17:13:11 +08:00
|
|
|
|
|
|
|
// SearchOrderByFlatMap is similar to SearchOrderByMap 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"],
|
|
|
|
}
|