|
@@ -521,21 +521,29 @@ func RecommendOrgFromPromote(ctx *context.Context) { |
|
|
ctx.ServerError("500", err) |
|
|
ctx.ServerError("500", err) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
resultOrg := make([]*models.User, 0) |
|
|
|
|
|
|
|
|
resultOrg := make([]map[string]interface{}, 0) |
|
|
for _, userName := range result { |
|
|
for _, userName := range result { |
|
|
user, err := models.GetUserByName(userName) |
|
|
user, err := models.GetUserByName(userName) |
|
|
if err == nil { |
|
|
if err == nil { |
|
|
resultOrg = append(resultOrg, user) |
|
|
|
|
|
|
|
|
userMap := make(map[string]interface{}) |
|
|
|
|
|
userMap["Name"] = user.Name |
|
|
|
|
|
userMap["ID"] = user.ID |
|
|
|
|
|
userMap["Avatar"] = user.RelAvatarLink() |
|
|
|
|
|
userMap["NumRepos"] = user.NumRepos |
|
|
|
|
|
userMap["NumTeams"] = user.NumTeams |
|
|
|
|
|
userMap["NumMembers"] = user.NumMembers |
|
|
|
|
|
resultOrg = append(resultOrg, userMap) |
|
|
} else { |
|
|
} else { |
|
|
log.Info("query user error," + err.Error()) |
|
|
log.Info("query user error," + err.Error()) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ctx.JSON(200, resultOrg) |
|
|
ctx.JSON(200, resultOrg) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func recommendFromPromote(url string) ([]string, error) { |
|
|
func recommendFromPromote(url string) ([]string, error) { |
|
|
resp, err := http.Get(url) |
|
|
resp, err := http.Get(url) |
|
|
if err != nil { |
|
|
|
|
|
|
|
|
if err != nil || resp.StatusCode != 200 { |
|
|
log.Info("Get organizations url error=" + err.Error()) |
|
|
log.Info("Get organizations url error=" + err.Error()) |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
@@ -569,9 +577,10 @@ func RecommendRepoFromPromote(ctx *context.Context) { |
|
|
ctx.ServerError("500", err) |
|
|
ctx.ServerError("500", err) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
resultRepo := make([]*models.Repository, 0) |
|
|
|
|
|
|
|
|
resultRepo := make([]map[string]interface{}, 0) |
|
|
|
|
|
//resultRepo := make([]*models.Repository, 0) |
|
|
for _, repoName := range result { |
|
|
for _, repoName := range result { |
|
|
tmpIndex := strings.Index(repoName, ".") |
|
|
|
|
|
|
|
|
tmpIndex := strings.Index(repoName, "/") |
|
|
if tmpIndex == -1 { |
|
|
if tmpIndex == -1 { |
|
|
log.Info("error repo name format.") |
|
|
log.Info("error repo name format.") |
|
|
} else { |
|
|
} else { |
|
@@ -579,7 +588,17 @@ func RecommendRepoFromPromote(ctx *context.Context) { |
|
|
repoName := strings.Trim(repoName[tmpIndex+1:], " ") |
|
|
repoName := strings.Trim(repoName[tmpIndex+1:], " ") |
|
|
repo, err := models.GetRepositoryByOwnerAndName(ownerName, repoName) |
|
|
repo, err := models.GetRepositoryByOwnerAndName(ownerName, repoName) |
|
|
if err == nil { |
|
|
if err == nil { |
|
|
resultRepo = append(resultRepo, repo) |
|
|
|
|
|
|
|
|
repoMap := make(map[string]interface{}) |
|
|
|
|
|
repoMap["ID"] = fmt.Sprint(repo.ID) |
|
|
|
|
|
repoMap["Name"] = repo.Name |
|
|
|
|
|
repoMap["OwnerName"] = repo.OwnerName |
|
|
|
|
|
repoMap["NumStars"] = repo.NumStars |
|
|
|
|
|
repoMap["NumForks"] = repo.NumForks |
|
|
|
|
|
repoMap["Description"] = repo.Description |
|
|
|
|
|
repoMap["NumWatchs"] = repo.NumWatches |
|
|
|
|
|
repoMap["Topics"] = repo.Topics |
|
|
|
|
|
repoMap["Avatar"] = repo.RelAvatarLink() |
|
|
|
|
|
resultRepo = append(resultRepo, repoMap) |
|
|
} else { |
|
|
} else { |
|
|
log.Info("query repo error," + err.Error()) |
|
|
log.Info("query repo error," + err.Error()) |
|
|
} |
|
|
} |
|
|