Browse Source

Merge branch 'V20220601' of git.openi.org.cn:OpenI/aiforge into grampus

pull/2379/head
lewis 3 years ago
parent
commit
606ab4df8a
7 changed files with 58 additions and 74 deletions
  1. +1
    -3
      models/user_business_analysis.go
  2. +4
    -32
      public/home/home.js
  3. +46
    -29
      routers/home.go
  4. +1
    -3
      routers/routes/routes.go
  5. +1
    -1
      templates/explore/repo_right.tmpl
  6. +4
    -5
      templates/user/dashboard/repolist.tmpl
  7. +1
    -1
      web_src/js/index.js

+ 1
- 3
models/user_business_analysis.go View File

@@ -927,7 +927,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time,
if err != nil { if err != nil {
log.Info("query commit code errr.") log.Info("query commit code errr.")
} else { } 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) CommitCodeSizeMapJson, _ := json.Marshal(CommitCodeSizeMap)
log.Info("CommitCodeSizeMapJson=" + string(CommitCodeSizeMapJson)) log.Info("CommitCodeSizeMapJson=" + string(CommitCodeSizeMapJson))
} }
@@ -1154,7 +1154,6 @@ func getUserIndexFromAnalysisAll(dateRecord UserBusinessAnalysisAll, ParaWeight
// 登录次数 0.10 // 登录次数 0.10
result = float64(dateRecord.CodeMergeCount) * getParaWeightValue("CodeMergeCount", ParaWeight, 0.2) result = float64(dateRecord.CodeMergeCount) * getParaWeightValue("CodeMergeCount", ParaWeight, 0.2)
result += float64(dateRecord.CommitCount) * getParaWeightValue("CommitCount", 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.IssueCount) * getParaWeightValue("IssueCount", ParaWeight, 0.2)
result += float64(dateRecord.CommentCount) * getParaWeightValue("CommentCount", ParaWeight, 0.2) result += float64(dateRecord.CommentCount) * getParaWeightValue("CommentCount", ParaWeight, 0.2)
result += float64(dateRecord.FocusRepoCount) * getParaWeightValue("FocusRepoCount", ParaWeight, 0.1) result += float64(dateRecord.FocusRepoCount) * getParaWeightValue("FocusRepoCount", ParaWeight, 0.1)
@@ -1237,7 +1236,6 @@ func getUserIndex(dateRecord UserBusinessAnalysis, ParaWeight map[string]float64
// 登录次数 0.10 // 登录次数 0.10
result = float64(dateRecord.CodeMergeCount) * getParaWeightValue("CodeMergeCount", ParaWeight, 0.2) result = float64(dateRecord.CodeMergeCount) * getParaWeightValue("CodeMergeCount", ParaWeight, 0.2)
result += float64(dateRecord.CommitCount) * getParaWeightValue("CommitCount", 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.IssueCount) * getParaWeightValue("IssueCount", ParaWeight, 0.2)
result += float64(dateRecord.CommentCount) * getParaWeightValue("CommentCount", ParaWeight, 0.2) result += float64(dateRecord.CommentCount) * getParaWeightValue("CommentCount", ParaWeight, 0.2)
result += float64(dateRecord.FocusRepoCount) * getParaWeightValue("FocusRepoCount", ParaWeight, 0.1) result += float64(dateRecord.FocusRepoCount) * getParaWeightValue("FocusRepoCount", ParaWeight, 0.1)


+ 4
- 32
public/home/home.js View File

@@ -418,44 +418,16 @@ queryRecommendData();
function queryRecommendData(){ function queryRecommendData(){
$.ajax({ $.ajax({
type:"GET", type:"GET",
url:"/recommend/org",
url:"/recommend/home",
headers: { headers: {
authorization:token, authorization:token,
}, },
dataType:"json", dataType:"json",
async:false, async:false,
success:function(json){ 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) { error:function(response) {
} }


+ 46
- 29
routers/home.go View File

@@ -99,6 +99,12 @@ func setRecommendURL(ctx *context.Context) {


func Dashboard(ctx *context.Context) { func Dashboard(ctx *context.Context) {
if ctx.IsSigned { 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 { if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm {
ctx.Data["Title"] = ctx.Tr("auth.active_your_account") ctx.Data["Title"] = ctx.Tr("auth.active_your_account")
ctx.HTML(200, user.TplActivate) ctx.HTML(200, user.TplActivate)
@@ -259,7 +265,11 @@ func ExploreRepos(ctx *context.Context) {
ctx.Data["PageIsExplore"] = true ctx.Data["PageIsExplore"] = true
ctx.Data["PageIsExploreRepositories"] = true ctx.Data["PageIsExploreRepositories"] = true
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled 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 var ownerID int64
if ctx.User != nil && !ctx.User.IsAdmin { if ctx.User != nil && !ctx.User.IsAdmin {
ownerID = ctx.User.ID ownerID = ctx.User.ID
@@ -434,7 +444,11 @@ func ExploreUsers(ctx *context.Context) {
ctx.Data["PageIsExplore"] = true ctx.Data["PageIsExplore"] = true
ctx.Data["PageIsExploreUsers"] = true ctx.Data["PageIsExploreUsers"] = true
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled 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{ RenderUserSearch(ctx, &models.SearchUserOptions{
Actor: ctx.User, Actor: ctx.User,
Type: models.UserTypeIndividual, Type: models.UserTypeIndividual,
@@ -471,7 +485,7 @@ func ExploreOrganizations(ctx *context.Context) {
return return
} }


recommendOrgs, err := GetRecommendOrg()
recommendOrgs, err := getRecommendOrg()
if err != nil { if err != nil {
log.Error("GetRecommendOrgInfos failed:%v", err.Error(), ctx.Data["MsgID"]) log.Error("GetRecommendOrgInfos failed:%v", err.Error(), ctx.Data["MsgID"])
ctx.ServerError("GetRecommendOrgInfos", err) ctx.ServerError("GetRecommendOrgInfos", err)
@@ -606,31 +620,31 @@ func ExploreImages(ctx *context.Context) {
} }


func ExploreDataAnalysisUserTrend(ctx *context.Context) { func ExploreDataAnalysisUserTrend(ctx *context.Context) {
ctx.Data["url_params"]="UserTrend"
ctx.Data["url_params"] = "UserTrend"
ctx.HTML(200, tplExploreExploreDataAnalysis) ctx.HTML(200, tplExploreExploreDataAnalysis)
} }
func ExploreDataAnalysisUserAnalysis(ctx *context.Context) { func ExploreDataAnalysisUserAnalysis(ctx *context.Context) {
ctx.Data["url_params"]="UserAnalysis"
ctx.Data["url_params"] = "UserAnalysis"
ctx.HTML(200, tplExploreExploreDataAnalysis) ctx.HTML(200, tplExploreExploreDataAnalysis)
} }
func ExploreDataAnalysisProTrend(ctx *context.Context) { func ExploreDataAnalysisProTrend(ctx *context.Context) {
ctx.Data["url_params"]="ProTrend"
ctx.Data["url_params"] = "ProTrend"
ctx.HTML(200, tplExploreExploreDataAnalysis) ctx.HTML(200, tplExploreExploreDataAnalysis)
} }
func ExploreDataAnalysisProAnalysis(ctx *context.Context) { func ExploreDataAnalysisProAnalysis(ctx *context.Context) {
ctx.Data["url_params"]="ProAnalysis"
ctx.Data["url_params"] = "ProAnalysis"
ctx.HTML(200, tplExploreExploreDataAnalysis) ctx.HTML(200, tplExploreExploreDataAnalysis)
} }
func ExploreDataAnalysisOverview(ctx *context.Context) { func ExploreDataAnalysisOverview(ctx *context.Context) {
ctx.Data["url_params"]="Overview"
ctx.Data["url_params"] = "Overview"
ctx.HTML(200, tplExploreExploreDataAnalysis) ctx.HTML(200, tplExploreExploreDataAnalysis)
} }
func ExploreDataAnalysisBrainAnalysis(ctx *context.Context) { func ExploreDataAnalysisBrainAnalysis(ctx *context.Context) {
ctx.Data["url_params"]="BrainAnalysis"
ctx.Data["url_params"] = "BrainAnalysis"
ctx.HTML(200, tplExploreExploreDataAnalysis) ctx.HTML(200, tplExploreExploreDataAnalysis)
} }
func ExploreDataAnalysis(ctx *context.Context) { func ExploreDataAnalysis(ctx *context.Context) {
ctx.Data["url_params"]=""
ctx.Data["url_params"] = ""
ctx.HTML(200, tplExploreExploreDataAnalysis) ctx.HTML(200, tplExploreExploreDataAnalysis)
} }


@@ -640,7 +654,7 @@ func NotFound(ctx *context.Context) {
ctx.NotFound("home.NotFound", nil) ctx.NotFound("home.NotFound", nil)
} }


func GetRecommendOrg() ([]map[string]interface{}, error) {
func getRecommendOrg() ([]map[string]interface{}, error) {
url := setting.RecommentRepoAddr + "organizations" url := setting.RecommentRepoAddr + "organizations"
result, err := repository.RecommendFromPromote(url) result, err := repository.RecommendFromPromote(url)


@@ -668,17 +682,18 @@ func GetRecommendOrg() ([]map[string]interface{}, error) {
} }
return resultOrg, nil 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) result, err := repository.RecommendFromPromote(url)


if err != nil { if err != nil {
return nil, err return nil, err
} }
imageInfo := make([]map[string]interface{}, 0)
imageInfo := make([]map[string]string, 0)
for i := 0; i < (len(result) - 1); i++ { for i := 0; i < (len(result) - 1); i++ {
line := result[i] line := result[i]
imageMap := make(map[string]interface{})
imageMap := make(map[string]string)
if line[0:4] == "url=" { if line[0:4] == "url=" {
url := line[4:] url := line[4:]
imageMap["url"] = url imageMap["url"] = url
@@ -731,15 +746,6 @@ func GetRankUser(index string) ([]map[string]interface{}, error) {
return resultOrg, nil 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) { func GetUserRankFromPromote(ctx *context.Context) {
index := ctx.Params("index") index := ctx.Params("index")
resultUserRank, err := GetRankUser(index) resultUserRank, err := GetRankUser(index)
@@ -750,13 +756,24 @@ func GetUserRankFromPromote(ctx *context.Context) {
ctx.JSON(200, resultUserRank) ctx.JSON(200, resultUserRank)
} }


func RecommendOrgFromPromote(ctx *context.Context) {
resultOrg, err := GetRecommendOrg()
func RecommendHomeInfo(ctx *context.Context) {
resultOrg, err := getRecommendOrg()
if err != nil { 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) { func RecommendRepoFromPromote(ctx *context.Context) {


+ 1
- 3
routers/routes/routes.go View File

@@ -323,10 +323,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/dashboard", routers.Dashboard) m.Get("/dashboard", routers.Dashboard)
go routers.SocketManager.Run() go routers.SocketManager.Run()
m.Get("/action/notification", routers.ActionNotification) 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/userrank/:index", routers.GetUserRankFromPromote) m.Get("/recommend/userrank/:index", routers.GetUserRankFromPromote)
m.Get("/recommend/imageinfo", routers.GetImageInfoFromPromote)
m.Post("/all/search/", routers.Search) m.Post("/all/search/", routers.Search)
m.Get("/all/search/", routers.EmptySearch) m.Get("/all/search/", routers.EmptySearch)
m.Get("/all/dosearch/", routers.SearchApi) m.Get("/all/dosearch/", routers.SearchApi)


+ 1
- 1
templates/explore/repo_right.tmpl View File

@@ -1,4 +1,4 @@
<a href="https://openi.org.cn/index.php?m=content&c=index&a=lists&catid=208" target="_blank"><img class="ui mini image" src="https://openi.org.cn/uploadfile/2022/0507/e8bdd42ed598f12.jpg" style="width:100%;"></a>
<a href="{{.image_link}}" target="_blank"><img class="ui mini image" src="{{.image_url}}" style="width:100%;"></a>


<div class="ui secondary pointing menu"> <div class="ui secondary pointing menu">
<div class="active item"> <div class="active item">


+ 4
- 5
templates/user/dashboard/repolist.tmpl View File

@@ -162,12 +162,11 @@
</div> </div>
</div> </div>
</div> </div>
</repo-search>

<div class="ui hidden divider"></div>
</repo-search>
<div class="ui hidden divider"></div>
<div> <div>
<a href="https://openi.org.cn/index.php?m=content&amp;c=index&amp;a=show&amp;catid=202&amp;id=221" target="_blank">
<img src="https://openi.org.cn/uploadfile/2022/0427/c45291e24e30f54.jpg" class="ui fluid image" alt="">
<a href="{{.image_link}}" target="_blank">
<img src="{{.image_url}}" class="ui fluid image" alt="">
</a> </a>
</div> </div>
</div> </div>

+ 1
- 1
web_src/js/index.js View File

@@ -4349,7 +4349,7 @@ function initVueDataset() {
q: this.searchDataItem q: this.searchDataItem
} }
}).then((res) => { }).then((res) => {
if (res.result_code == '0') {
if (res.data.result_code == '0') {
this.currentRepoDataset = JSON.parse(res.data.data) this.currentRepoDataset = JSON.parse(res.data.data)
const checkStatuDataset = this.currentRepoDataset.filter(item => item.DecompressState === 2) const checkStatuDataset = this.currentRepoDataset.filter(item => item.DecompressState === 2)
if (checkStatuDataset.length > 0) { if (checkStatuDataset.length > 0) {


Loading…
Cancel
Save