Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.4.2^2
zouap 3 years ago
parent
commit
079e2aed7a
1 changed files with 8 additions and 4 deletions
  1. +8
    -4
      routers/search.go

+ 8
- 4
routers/search.go View File

@@ -202,17 +202,21 @@ func searchRepoByLabel(ctx *context.Context, Key string, Page int, PageSize int)

func getSortSingle(SortBy string, ascending bool) elastic.Sorter {
var sort elastic.Sorter
if SortBy == "default" {
sort = elastic.NewScoreSort()
if SortBy != "" {
if SortBy == "default" {
sort = elastic.NewScoreSort()
} else {
sort = elastic.NewFieldSort(SortBy).Order(ascending)
}
} else {
sort = elastic.NewFieldSort(SortBy).Order(ascending)
sort = elastic.NewScoreSort()
}
return sort
}

func getSort(SortBy string, ascending bool, secondSortBy string, secondAscending bool) []elastic.Sorter {
sort := make([]elastic.Sorter, 0)
if SortBy == "default" {
if SortBy == "default" || SortBy == "" {
sort = append(sort, elastic.NewScoreSort())
if secondSortBy != "" {
log.Info("SortBy=" + SortBy + " secondSortBy=" + secondSortBy)


Loading…
Cancel
Save