Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
pull/1036/head
zouap 3 years ago
parent
commit
8908c9f43c
1 changed files with 57 additions and 1 deletions
  1. +57
    -1
      models/user_business_analysis.go

+ 57
- 1
models/user_business_analysis.go View File

@@ -231,7 +231,7 @@ func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime ti
log.Info("start to count other user info data")
sess := x.NewSession()
defer sess.Close()
sess.Select("`user`.*").Table("user").Where("type=1 and is_active=true")
sess.Select("`user`.*").Table("user").Where("type != 1 and is_active=true")
userList := make([]*User, 0)
sess.Find(&userList)

@@ -267,6 +267,7 @@ func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime ti
SolveIssueCountMap := querySolveIssue(start_unix, end_unix)
CreateRepoCountMap := queryUserCreateRepo(start_unix, end_unix)
LoginCountMap := queryLoginCount(start_unix, end_unix)
OpenIIndexMap := queryUserRepoOpenIIndex(start_unix, end_unix)

statictisSess := xStatistic.NewSession()
defer statictisSess.Close()
@@ -361,6 +362,12 @@ func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime ti
dateRecord.LoginCount = LoginCountMap[dateRecord.ID]
}

if _, ok := OpenIIndexMap[dateRecord.ID]; !ok {
dateRecord.OpenIIndex = 0
} else {
dateRecord.OpenIIndex = int(OpenIIndexMap[dateRecord.ID] * 100)
}

dateRecord.CommitModelCount = 0

statictisSess.Insert(&dateRecord)
@@ -545,6 +552,55 @@ func queryUserCreateRepo(start_unix int64, end_unix int64) map[int64]int {
return resultMap
}

func queryUserRepoOpenIIndex(start_unix int64, end_unix int64) map[int64]float64 {
statictisSess := xStatistic.NewSession()
defer statictisSess.Close()
statictisSess.Select("repo_id,radar_total").Table("repo_statistic").Where("created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix))
repoStatisticList := make([]*RepoStatistic, 0)
statictisSess.Find(&repoStatisticList)
repoOpenIIndexMap := make(map[int64]float64)
log.Info("query repo_statistic size=" + fmt.Sprint(len(repoStatisticList)))
for _, repoRecord := range repoStatisticList {
if _, ok := repoOpenIIndexMap[repoRecord.RepoID]; !ok {
repoOpenIIndexMap[repoRecord.RepoID] = repoRecord.RadarTotal
}
}

sess := x.NewSession()
defer sess.Close()
sess.Select("id,owner_id,name").Table("repository").Where("is_fork=false and created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix))
repoList := make([]*Repository, 0)
sess.Find(&repoList)

userMap := make(map[int64]float64)

log.Info("query Repository size=" + fmt.Sprint(len(repoList)))
for _, repoRecord := range repoList {
if _, ok := userMap[repoRecord.OwnerID]; !ok {
if _, ok := repoOpenIIndexMap[repoRecord.ID]; !ok {
userMap[repoRecord.OwnerID] = repoOpenIIndexMap[repoRecord.ID]
}
}
}

//query collaboration
sess.Select("repo_id,user_id,mode").Table("collaboration")
collaborationList := make([]*Collaboration, 0)
sess.Find(&collaborationList)
for _, collaborationRecord := range collaborationList {
if _, ok := userMap[collaborationRecord.UserID]; !ok {
if _, ok := repoOpenIIndexMap[collaborationRecord.RepoID]; !ok {
userMap[collaborationRecord.UserID] = repoOpenIIndexMap[collaborationRecord.RepoID]
}
} else {
if _, ok := repoOpenIIndexMap[collaborationRecord.RepoID]; !ok {
userMap[collaborationRecord.UserID] += repoOpenIIndexMap[collaborationRecord.RepoID]
}
}
}
return userMap
}

func queryLoginCount(start_unix int64, end_unix int64) map[int64]int {
statictisSess := xStatistic.NewSession()
defer statictisSess.Close()


Loading…
Cancel
Save