diff --git a/public/home/search.js b/public/home/search.js index 1953c7204..cf785d81d 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -188,7 +188,7 @@ function displayPrResult(page,jsonResult,onlyReturnNum,keyword){ $('#obj_desc').text("合并请求"); $('#child_total').text(total); - setIssueOrPrInnerHtml(data); + setIssueOrPrInnerHtml(data,"pulls"); } } @@ -235,6 +235,22 @@ var taskDesc={ "speech_synthesis":"语音合成" }; +function getCategoryDesc(key){ + var re = categoryDesc[key]; + if(isEmpty(re)){ + return key; + } + return re; +} + +function getTaskDesc(key){ + var re = categoryDesc[key]; + if(isEmpty(re)){ + return key; + } + return re; +} + function displayDataSetResult(page,jsonResult,onlyReturnNum,keyword){ var data = jsonResult.Result; var total = jsonResult.Total; @@ -257,10 +273,10 @@ function displayDataSetResult(page,jsonResult,onlyReturnNum,keyword){ html += "
" + recordMap["content"] + "
"; html +=""; html +=" "; - html +=" " + recordMap["repoUrl"] +"#" + recordMap["id"] + ""; + html +=" " + recordMap["repoUrl"] +"#" + recordMap["id"] + ""; html +=" "; if(isEmpty(recordMap["is_closed"]) || recordMap["is_closed"]=="f"){ html += "关闭"; @@ -415,7 +431,7 @@ function displayIssueResult(page,jsonResult,onlyReturnNum,keyword){ $('#obj_desc').text("任务"); $('#child_total').text(total); - setIssueOrPrInnerHtml(data); + setIssueOrPrInnerHtml(data,"issues"); } } @@ -473,7 +489,7 @@ function displayRepoResult(page,jsonResult,onlyReturnNum,keyword){ } html +="
"; - html +=" " +recordMap["num_watches"] + " " + recordMap["num_stars"] + " " + recordMap["num_forks"] +" "; + html +=" " +recordMap["num_watches"] + " " + recordMap["num_stars"] + " " + recordMap["num_forks"] +" "; html +=" 最后更新于 " + getTime(recordMap["updated_unix"],currentTime) +""; if(!isEmpty(recordMap["lang"])){ html +=" " + recordMap["lang"] + ""; diff --git a/routers/search.go b/routers/search.go index 88a14f588..3d38a6053 100644 --- a/routers/search.go +++ b/routers/search.go @@ -194,8 +194,6 @@ func makeRepoResult(sRes *elastic.SearchResult, Key string, OnlyReturnNum bool) } record["hightTopics"] = jsonStrToArray(getLabelValue("topics", recordSource, hit.Highlight)) - //log.Info("hight[\"topics\"]=" + getLabelValue("topics", recordSource, hit.Highlight)) - record["num_watches"] = recordSource["num_watches"] record["num_stars"] = recordSource["num_stars"] record["num_forks"] = recordSource["num_forks"] @@ -205,11 +203,6 @@ func makeRepoResult(sRes *elastic.SearchResult, Key string, OnlyReturnNum bool) log.Info("topicsStr=" + topicsStr) if topicsStr != "null" { record["topics"] = jsonStrToArray(topicsStr) - // topicsStr = strings.Replace(topicsStr, "\"", "", -1) - // topicsStr = topicsStr[1 : len(topicsStr)-1] - // log.Info("record[\"topics\"]=" + topicsStr) - // topicstmp := strings.Split(topicsStr, ",") - // record["topics"] = topicstmp } } if recordSource["avatar"] != nil { @@ -478,7 +471,7 @@ func makeDatasetResult(sRes *elastic.SearchResult, Key string, OnlyReturnNum boo } else { record["description"] = "" } - record["file_name"] = recordSource["file_name"] + record["file_name"] = getLabelValue("file_name", recordSource, hit.Highlight) record["task"] = recordSource["task"] record["download_times"] = recordSource["download_times"] record["created_unix"] = recordSource["created_unix"] @@ -660,6 +653,8 @@ func searchPR(ctx *context.Context, TableName string, Key string, Page int, Page } res, err := client.Search(TableName).Query(boolQ).Sort(SortBy, ascending).From((Page - 1) * PageSize).Size(PageSize).Highlight(queryHighlight("name", "content", "comment")).Do(ctx.Req.Context()) if err == nil { + searchJson, _ := json.Marshal(res) + log.Info("searchJson=" + string(searchJson)) result := makeIssueResult(res, Key, OnlyReturnNum) ctx.JSON(200, result) } else {