|
|
|
@@ -107,25 +107,13 @@ func GetRecommendCourseKeyWords() ([]string, error) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func GetRecommendRepoFromPromote(filename string) ([]map[string]interface{}, error) { |
|
|
|
func GetRecommendRepoFromPromote(repoMap []map[string]string) ([]map[string]interface{}, error) { |
|
|
|
resultRepo := make([]map[string]interface{}, 0) |
|
|
|
url := setting.RecommentRepoAddr + filename |
|
|
|
result, err := RecommendFromPromote(url) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return resultRepo, err |
|
|
|
} |
|
|
|
|
|
|
|
//resultRepo := make([]*models.Repository, 0) |
|
|
|
for _, repoName := range result { |
|
|
|
tmpIndex1 := strings.Index(repoName, "##") |
|
|
|
for _, record := range repoMap { |
|
|
|
repoName := record["project_url"] |
|
|
|
//log.Info("repoName=" + repoName + " tmpIndex1=" + fmt.Sprint(tmpIndex1) + " len(repoName)=" + fmt.Sprint(len(repoName))) |
|
|
|
repoLabel := "" |
|
|
|
if tmpIndex1 != -1 { |
|
|
|
repoLabel = strings.Trim(repoName[tmpIndex1+2:], " ") |
|
|
|
repoName = strings.Trim(repoName[0:tmpIndex1], " ") |
|
|
|
} |
|
|
|
tmpIndex := strings.Index(repoName, "/") |
|
|
|
if tmpIndex == -1 { |
|
|
|
log.Info("error repo name format.") |
|
|
|
@@ -138,7 +126,8 @@ func GetRecommendRepoFromPromote(filename string) ([]map[string]interface{}, err |
|
|
|
repoMap["ID"] = fmt.Sprint(repo.ID) |
|
|
|
repoMap["Name"] = repo.Name |
|
|
|
repoMap["Alias"] = repo.Alias |
|
|
|
repoMap["Label"] = repoLabel |
|
|
|
repoMap["Label"] = record["class"] |
|
|
|
repoMap["Label_en"] = record["class_en"] |
|
|
|
repoMap["OwnerName"] = repo.OwnerName |
|
|
|
repoMap["NumStars"] = repo.NumStars |
|
|
|
repoMap["NumForks"] = repo.NumForks |
|
|
|
|