diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 56702e1f7..87c8b2355 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -893,7 +893,8 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, //insert userMetrics table var useMetrics UserMetrics - useMetrics.CountDate = CountDate.Unix() + metricCountDate := time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 0, 0, 0, 0, currentTimeNow.Location()) + useMetrics.CountDate = metricCountDate.Unix() statictisSess.Delete(&useMetrics) useMetrics.ActivateRegistUser = getMapKeyStringValue("ActivateRegistUser", userMetrics) diff --git a/routers/home.go b/routers/home.go index c36bd6194..4a6d1f4fb 100755 --- a/routers/home.go +++ b/routers/home.go @@ -667,6 +667,31 @@ func GetRecommendOrg() ([]map[string]interface{}, error) { return resultOrg, nil } +func GetImageInfo() ([]map[string]interface{}, error) { + url := setting.RecommentRepoAddr + "picture_info" + result, err := repository.RecommendFromPromote(url) + + if err != nil { + return nil, err + } + imageInfo := make([]map[string]interface{}, 0) + for i := 0; i < (len(result) - 1); i++ { + line := result[i] + imageMap := make(map[string]interface{}) + if line[0:4] == "url=" { + url := line[4:] + imageMap["url"] = url + if result[i+1][0:11] == "image_link=" { + image_link := result[i+1][11:] + imageMap["image_link"] = image_link + } + } + imageInfo = append(imageInfo, imageMap) + i = i + 1 + } + return imageInfo, nil +} + func GetRankUser(index string) ([]map[string]interface{}, error) { url := setting.RecommentRepoAddr + "user_rank_" + index result, err := repository.RecommendFromPromote(url) @@ -705,6 +730,15 @@ func GetRankUser(index string) ([]map[string]interface{}, error) { return resultOrg, nil } +func GetImageInfoFromPromote(ctx *context.Context) { + imageInfo, err := GetImageInfo() + if err != nil { + ctx.ServerError("500", err) + return + } + ctx.JSON(200, imageInfo) +} + func GetUserRankFromPromote(ctx *context.Context) { index := ctx.Params("index") resultUserRank, err := GetRankUser(index) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index a695a5a1e..1ff407e82 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -326,6 +326,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/recommend/org", routers.RecommendOrgFromPromote) m.Get("/recommend/repo", routers.RecommendRepoFromPromote) m.Get("/recommend/userrank/:index", routers.GetUserRankFromPromote) + m.Get("/recommend/imageinfo", routers.GetImageInfoFromPromote) m.Post("/all/search/", routers.Search) m.Get("/all/search/", routers.EmptySearch) m.Get("/all/dosearch/", routers.SearchApi) diff --git a/templates/explore/repo_right.tmpl b/templates/explore/repo_right.tmpl index 12a3ffadb..5e05e797b 100644 --- a/templates/explore/repo_right.tmpl +++ b/templates/explore/repo_right.tmpl @@ -1,4 +1,4 @@ - +