Browse Source

恢复搜索代码

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.4.1^2
zouap 3 years ago
parent
commit
51e351eea8
1 changed files with 14 additions and 10 deletions
  1. +14
    -10
      routers/search.go

+ 14
- 10
routers/search.go View File

@@ -68,23 +68,23 @@ func SearchApi(ctx *context.Context) {
if OnlySearchLabel {
searchRepoByLabel(ctx, Key, Page, PageSize)
} else {
searchRepo(ctx, "repository-es-index", Key, Page, PageSize, OnlyReturnNum)
searchRepo(ctx, "repository-es-index"+setting.INDEXPOSTFIX, Key, Page, PageSize, OnlyReturnNum)
}
return
} else if TableName == "issue" {
searchIssueOrPr(ctx, "issue-es-index", Key, Page, PageSize, OnlyReturnNum, "f")
searchIssueOrPr(ctx, "issue-es-index"+setting.INDEXPOSTFIX, Key, Page, PageSize, OnlyReturnNum, "f")
return
} else if TableName == "user" {
searchUserOrOrg(ctx, "user-es-index", Key, Page, PageSize, true, OnlyReturnNum)
searchUserOrOrg(ctx, "user-es-index"+setting.INDEXPOSTFIX, Key, Page, PageSize, true, OnlyReturnNum)
return
} else if TableName == "org" {
searchUserOrOrg(ctx, "user-es-index", Key, Page, PageSize, false, OnlyReturnNum)
searchUserOrOrg(ctx, "user-es-index"+setting.INDEXPOSTFIX, Key, Page, PageSize, false, OnlyReturnNum)
return
} else if TableName == "dataset" {
searchDataSet(ctx, "dataset-es-index", Key, Page, PageSize, OnlyReturnNum)
searchDataSet(ctx, "dataset-es-index"+setting.INDEXPOSTFIX, Key, Page, PageSize, OnlyReturnNum)
return
} else if TableName == "pr" {
searchIssueOrPr(ctx, "issue-es-index", Key, Page, PageSize, OnlyReturnNum, "t")
searchIssueOrPr(ctx, "issue-es-index"+setting.INDEXPOSTFIX, Key, Page, PageSize, OnlyReturnNum, "t")
//searchPR(ctx, "issue-es-index", Key, Page, PageSize, OnlyReturnNum)
return
}
@@ -573,7 +573,8 @@ func trimFontHtml(text []rune) string {
startRune := rune('<')
endRune := rune('>')
count := 0
for i := 0; i < len(text); i++ {
i := 0
for ; i < len(text); i++ {
if text[i] == startRune { //start <
re := false
j := i + 1
@@ -592,11 +593,14 @@ func trimFontHtml(text []rune) string {
} else {
return string(text[0:i])
}

}
}
}
return string(text)
if count%2 == 1 {
return string(text[0:i]) + "</font>"
} else {
return string(text[0:i])
}
}

func trimHrefHtml(result string) string {
@@ -1125,7 +1129,7 @@ func makePrivateIssueOrPr(issues []*models.Issue, res *SearchRes, Key string, la
record["num_comments"] = issue.NumComments
record["is_closed"] = issue.IsClosed
record["updated_unix"] = issue.UpdatedUnix
record["updated_html"] = timeutil.TimeSinceUnix(repo.UpdatedUnix, language)
record["updated_html"] = timeutil.TimeSinceUnix(issue.UpdatedUnix, language)
res.Result = append(res.Result, record)
}
}


Loading…
Cancel
Save