From 15404d8bd1e9b38198c4fc66423acc3c742aa920 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 20 May 2022 15:19:52 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3SQL=E8=AF=AD=E5=8F=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 4 +--- routers/routes/routes.go | 1 + routers/user/auth.go | 3 +++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 56e591dea..5d77e876b 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -778,7 +778,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, if err != nil { log.Info("query commit code errr.") } else { - log.Info("query commit code size, len=" + fmt.Sprint(len(CommitCodeSizeMap))) + //log.Info("query commit code size, len=" + fmt.Sprint(len(CommitCodeSizeMap))) CommitCodeSizeMapJson, _ := json.Marshal(CommitCodeSizeMap) log.Info("CommitCodeSizeMapJson=" + string(CommitCodeSizeMapJson)) } @@ -1013,7 +1013,6 @@ func getUserIndexFromAnalysisAll(dateRecord UserBusinessAnalysisAll, ParaWeight // 登录次数 0.10 result = float64(dateRecord.CodeMergeCount) * getParaWeightValue("CodeMergeCount", ParaWeight, 0.2) result += float64(dateRecord.CommitCount) * getParaWeightValue("CommitCount", ParaWeight, 0.2) - log.Info("1 result=" + fmt.Sprint(result)) result += float64(dateRecord.IssueCount) * getParaWeightValue("IssueCount", ParaWeight, 0.2) result += float64(dateRecord.CommentCount) * getParaWeightValue("CommentCount", ParaWeight, 0.2) result += float64(dateRecord.FocusRepoCount) * getParaWeightValue("FocusRepoCount", ParaWeight, 0.1) @@ -1096,7 +1095,6 @@ func getUserIndex(dateRecord UserBusinessAnalysis, ParaWeight map[string]float64 // 登录次数 0.10 result = float64(dateRecord.CodeMergeCount) * getParaWeightValue("CodeMergeCount", ParaWeight, 0.2) result += float64(dateRecord.CommitCount) * getParaWeightValue("CommitCount", ParaWeight, 0.2) - log.Info("2 result=" + fmt.Sprint(result)) result += float64(dateRecord.IssueCount) * getParaWeightValue("IssueCount", ParaWeight, 0.2) result += float64(dateRecord.CommentCount) * getParaWeightValue("CommentCount", ParaWeight, 0.2) result += float64(dateRecord.FocusRepoCount) * getParaWeightValue("FocusRepoCount", ParaWeight, 0.1) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 4c3f5f472..85130ec8f 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -364,6 +364,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/user", func() { m.Get("/login", user.SignIn) m.Get("/login/cloud_brain", user.SignInCloudBrain) + m.Post("/login/kanban", user.SignInPostAPI) m.Post("/login", bindIgnErr(auth.SignInForm{}), user.SignInPost) m.Group("", func() { m.Combo("/login/openid"). diff --git a/routers/user/auth.go b/routers/user/auth.go index a02cf24dc..12cc41987 100755 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -175,6 +175,9 @@ func SignInCloudBrain(ctx *context.Context) { ctx.HTML(200, tplSignInCloudBrain) } +func SignInPostAPI(ctx *context.Context) { + log.Info("22222222222222222222222") +} // SignInPost response for sign in request func SignInPost(ctx *context.Context, form auth.SignInForm) { From 7921a9a21ecded4d693f5dc4d16e0e6632965a20 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 1 Jun 2022 09:35:43 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=BD=93=E5=89=8D=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/index.js b/web_src/js/index.js index 6e10f2f75..34b5febc5 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -4349,7 +4349,7 @@ function initVueDataset() { q: this.searchDataItem } }).then((res) => { - if (res.result_code == '0') { + if (res.data.result_code == '0') { this.currentRepoDataset = JSON.parse(res.data.data) const checkStatuDataset = this.currentRepoDataset.filter(item => item.DecompressState === 2) if (checkStatuDataset.length > 0) { From 7f0e070ae2e5131a406446e4050d8df5ec6300e2 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 1 Jun 2022 09:52:07 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/home.go | 75 +++++++++++++++++++++------------- routers/routes/routes.go | 8 ++-- routers/user/auth.go | 3 -- templates/explore/repo_right.tmpl | 2 +- templates/user/dashboard/repolist.tmpl | 6 +++ 5 files changed, 57 insertions(+), 37 deletions(-) diff --git a/routers/home.go b/routers/home.go index e37cacb01..38acffb2f 100755 --- a/routers/home.go +++ b/routers/home.go @@ -99,6 +99,12 @@ func setRecommendURL(ctx *context.Context) { func Dashboard(ctx *context.Context) { if ctx.IsSigned { + pictureInfo, err := getImageInfo("dashboard-picture") + if err == nil && len(pictureInfo) > 0 { + log.Info("set image info=" + pictureInfo[0]["url"]) + ctx.Data["image_url"] = pictureInfo[0]["url"] + ctx.Data["image_link"] = pictureInfo[0]["image_link"] + } if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm { ctx.Data["Title"] = ctx.Tr("auth.active_your_account") ctx.HTML(200, user.TplActivate) @@ -259,7 +265,11 @@ func ExploreRepos(ctx *context.Context) { ctx.Data["PageIsExplore"] = true ctx.Data["PageIsExploreRepositories"] = true ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled - + pictureInfo, err := getImageInfo("explore-user-picture") + if err == nil && len(pictureInfo) > 0 { + ctx.Data["image_url"] = pictureInfo[0]["url"] + ctx.Data["image_link"] = pictureInfo[0]["image_link"] + } var ownerID int64 if ctx.User != nil && !ctx.User.IsAdmin { ownerID = ctx.User.ID @@ -434,7 +444,11 @@ func ExploreUsers(ctx *context.Context) { ctx.Data["PageIsExplore"] = true ctx.Data["PageIsExploreUsers"] = true ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled - + pictureInfo, err := getImageInfo("explore-user-picture") + if err == nil && len(pictureInfo) > 0 { + ctx.Data["image_url"] = pictureInfo[0]["url"] + ctx.Data["image_link"] = pictureInfo[0]["image_link"] + } RenderUserSearch(ctx, &models.SearchUserOptions{ Actor: ctx.User, Type: models.UserTypeIndividual, @@ -471,7 +485,7 @@ func ExploreOrganizations(ctx *context.Context) { return } - recommendOrgs, err := GetRecommendOrg() + recommendOrgs, err := getRecommendOrg() if err != nil { log.Error("GetRecommendOrgInfos failed:%v", err.Error(), ctx.Data["MsgID"]) ctx.ServerError("GetRecommendOrgInfos", err) @@ -606,31 +620,31 @@ func ExploreImages(ctx *context.Context) { } func ExploreDataAnalysisUserTrend(ctx *context.Context) { - ctx.Data["url_params"]="UserTrend" + ctx.Data["url_params"] = "UserTrend" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysisUserAnalysis(ctx *context.Context) { - ctx.Data["url_params"]="UserAnalysis" + ctx.Data["url_params"] = "UserAnalysis" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysisProTrend(ctx *context.Context) { - ctx.Data["url_params"]="ProTrend" + ctx.Data["url_params"] = "ProTrend" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysisProAnalysis(ctx *context.Context) { - ctx.Data["url_params"]="ProAnalysis" + ctx.Data["url_params"] = "ProAnalysis" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysisOverview(ctx *context.Context) { - ctx.Data["url_params"]="Overview" + ctx.Data["url_params"] = "Overview" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysisBrainAnalysis(ctx *context.Context) { - ctx.Data["url_params"]="BrainAnalysis" + ctx.Data["url_params"] = "BrainAnalysis" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysis(ctx *context.Context) { - ctx.Data["url_params"]="" + ctx.Data["url_params"] = "" ctx.HTML(200, tplExploreExploreDataAnalysis) } @@ -640,7 +654,7 @@ func NotFound(ctx *context.Context) { ctx.NotFound("home.NotFound", nil) } -func GetRecommendOrg() ([]map[string]interface{}, error) { +func getRecommendOrg() ([]map[string]interface{}, error) { url := setting.RecommentRepoAddr + "organizations" result, err := repository.RecommendFromPromote(url) @@ -668,17 +682,18 @@ func GetRecommendOrg() ([]map[string]interface{}, error) { } return resultOrg, nil } -func GetImageInfo() ([]map[string]interface{}, error) { - url := setting.RecommentRepoAddr + "picture_info" + +func getImageInfo(filename string) ([]map[string]string, error) { + url := setting.RecommentRepoAddr + filename result, err := repository.RecommendFromPromote(url) if err != nil { return nil, err } - imageInfo := make([]map[string]interface{}, 0) + imageInfo := make([]map[string]string, 0) for i := 0; i < (len(result) - 1); i++ { line := result[i] - imageMap := make(map[string]interface{}) + imageMap := make(map[string]string) if line[0:4] == "url=" { url := line[4:] imageMap["url"] = url @@ -731,15 +746,6 @@ 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) @@ -750,13 +756,24 @@ func GetUserRankFromPromote(ctx *context.Context) { ctx.JSON(200, resultUserRank) } -func RecommendOrgFromPromote(ctx *context.Context) { - resultOrg, err := GetRecommendOrg() +func RecommendHomeInfo(ctx *context.Context) { + resultOrg, err := getRecommendOrg() if err != nil { - ctx.ServerError("500", err) - return + log.Info("error." + err.Error()) + } + resultRepo, err := repository.GetRecommendRepoFromPromote("projects") + if err != nil { + log.Info("error." + err.Error()) + } + resultImage, err := getImageInfo("picture_info") + if err != nil { + log.Info("error." + err.Error()) } - ctx.JSON(200, resultOrg) + mapInterface := make(map[string]interface{}) + mapInterface["org"] = resultOrg + mapInterface["repo"] = resultRepo + mapInterface["image"] = resultImage + ctx.JSON(http.StatusOK, mapInterface) } func RecommendRepoFromPromote(ctx *context.Context) { diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 85130ec8f..12d0e1cf8 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -323,10 +323,11 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/dashboard", routers.Dashboard) go routers.SocketManager.Run() m.Get("/action/notification", routers.ActionNotification) - m.Get("/recommend/org", routers.RecommendOrgFromPromote) - m.Get("/recommend/repo", routers.RecommendRepoFromPromote) + m.Get("/recommend/home", routers.RecommendHomeInfo) + //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.Get("/recommend/imageinfo", routers.GetImageInfoFromPromote) m.Post("/all/search/", routers.Search) m.Get("/all/search/", routers.EmptySearch) m.Get("/all/dosearch/", routers.SearchApi) @@ -364,7 +365,6 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/user", func() { m.Get("/login", user.SignIn) m.Get("/login/cloud_brain", user.SignInCloudBrain) - m.Post("/login/kanban", user.SignInPostAPI) m.Post("/login", bindIgnErr(auth.SignInForm{}), user.SignInPost) m.Group("", func() { m.Combo("/login/openid"). diff --git a/routers/user/auth.go b/routers/user/auth.go index 12cc41987..a02cf24dc 100755 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -175,9 +175,6 @@ func SignInCloudBrain(ctx *context.Context) { ctx.HTML(200, tplSignInCloudBrain) } -func SignInPostAPI(ctx *context.Context) { - log.Info("22222222222222222222222") -} // SignInPost response for sign in request func SignInPost(ctx *context.Context, form auth.SignInForm) { diff --git a/templates/explore/repo_right.tmpl b/templates/explore/repo_right.tmpl index 5e05e797b..cf0b7d349 100644 --- a/templates/explore/repo_right.tmpl +++ b/templates/explore/repo_right.tmpl @@ -1,4 +1,4 @@ - + + +
+ + + +
From 7bf2e47e10104f780dd2569007f8c16bc69597f7 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 1 Jun 2022 09:57:43 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- public/home/home.js | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/public/home/home.js b/public/home/home.js index 3b2a34f06..2affefddd 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -418,44 +418,16 @@ queryRecommendData(); function queryRecommendData(){ $.ajax({ type:"GET", - url:"/recommend/org", + url:"/recommend/home", headers: { authorization:token, }, dataType:"json", async:false, success:function(json){ - displayOrg(json); - }, - error:function(response) { - } - }); - - $.ajax({ - type:"GET", - url:"/recommend/repo", - headers: { - authorization:token, - }, - dataType:"json", - async:false, - success:function(json){ - displayRepo(json); - }, - error:function(response) { - } - }); - - $.ajax({ - type:"GET", - url:"/recommend/imageinfo", - headers: { - authorization:token, - }, - dataType:"json", - async:false, - success:function(json){ - displayActivity(json); + displayOrg(json.org); + displayRepo(json.repo); + displayActivity(json.image) }, error:function(response) { } From 978286da0aad6f770f9ac518231a977969e67ab4 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 1 Jun 2022 10:10:08 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/routes/routes.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 12d0e1cf8..7ba8fe61a 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -324,10 +324,7 @@ func RegisterRoutes(m *macaron.Macaron) { go routers.SocketManager.Run() m.Get("/action/notification", routers.ActionNotification) m.Get("/recommend/home", routers.RecommendHomeInfo) - //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)