2023-05-08 05:36:54 -04:00
|
|
|
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package repo
|
|
|
|
|
|
|
|
import "code.gitea.io/gitea/models/db"
|
|
|
|
|
2024-06-15 02:45:02 -04:00
|
|
|
// OrderByMap represents all possible search order
|
|
|
|
var OrderByMap = map[string]map[string]db.SearchOrderBy{
|
2023-05-08 05:36:54 -04:00
|
|
|
"asc": {
|
2024-06-15 00:48:52 -04: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 05:36:54 -04:00
|
|
|
},
|
|
|
|
"desc": {
|
2024-06-15 00:48:52 -04: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 05:36:54 -04:00
|
|
|
},
|
|
|
|
}
|
2024-06-13 05:13:11 -04:00
|
|
|
|
2024-06-15 02:45:02 -04:00
|
|
|
// OrderByFlatMap is similar to OrderByMap but use human language keywords
|
2024-06-13 05:13:11 -04:00
|
|
|
// to decide between asc and desc
|
2024-06-15 02:45:02 -04:00
|
|
|
var OrderByFlatMap = map[string]db.SearchOrderBy{
|
|
|
|
"newest": OrderByMap["desc"]["created"],
|
|
|
|
"oldest": OrderByMap["asc"]["created"],
|
2024-10-19 08:11:38 -04:00
|
|
|
"recentupdate": OrderByMap["desc"]["updated"],
|
2024-06-15 02:45:02 -04:00
|
|
|
"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"],
|
2024-06-13 05:13:11 -04:00
|
|
|
}
|