|
|
@@ -7,6 +7,8 @@ package routers |
|
|
|
|
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"fmt" |
|
|
|
"io/ioutil" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
|
|
|
|
@@ -511,3 +513,35 @@ func NotFound(ctx *context.Context) { |
|
|
|
ctx.Data["Title"] = "Page Not Found" |
|
|
|
ctx.NotFound("home.NotFound", nil) |
|
|
|
} |
|
|
|
func RecommendOrgFromPromote(ctx *context.Context) { |
|
|
|
url := setting.RecommentRepoAddr + "organizations" |
|
|
|
recommendFromPromote(ctx, url) |
|
|
|
} |
|
|
|
|
|
|
|
func recommendFromPromote(ctx *context.Context, url string) { |
|
|
|
resp, err := http.Get(url) |
|
|
|
if err != nil { |
|
|
|
log.Info("Get organizations url error=" + err.Error()) |
|
|
|
ctx.ServerError("QueryTrainJobList:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
bytes, err := ioutil.ReadAll(resp.Body) |
|
|
|
resp.Body.Close() |
|
|
|
if err != nil { |
|
|
|
log.Info("Get organizations url error=" + err.Error()) |
|
|
|
ctx.ServerError("QueryTrainJobList:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
allLineStr := string(bytes) |
|
|
|
lines := strings.Split(allLineStr, "\n") |
|
|
|
for i, line := range lines { |
|
|
|
log.Info("i=" + fmt.Sprint(i) + " line=" + line) |
|
|
|
} |
|
|
|
ctx.JSON(http.StatusOK, lines) |
|
|
|
} |
|
|
|
|
|
|
|
func RecommendRepoFromPromote(ctx *context.Context) { |
|
|
|
url := setting.RecommentRepoAddr + "projects" |
|
|
|
recommendFromPromote(ctx, url) |
|
|
|
} |