|
|
@@ -1,6 +1,7 @@ |
|
|
|
package models |
|
|
|
|
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"time" |
|
|
|
|
|
|
@@ -64,7 +65,7 @@ type UserBusinessAnalysis struct { |
|
|
|
LoginCount int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
|
|
//openi index |
|
|
|
OpenIIndex int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
OpenIIndex float64 `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
|
|
//user |
|
|
|
Email string `xorm:"NOT NULL"` |
|
|
@@ -267,6 +268,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 +363,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 = OpenIIndexMap[dateRecord.ID] |
|
|
|
} |
|
|
|
|
|
|
|
dateRecord.CommitModelCount = 0 |
|
|
|
|
|
|
|
statictisSess.Insert(&dateRecord) |
|
|
@@ -545,6 +553,62 @@ 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") |
|
|
|
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) |
|
|
|
|
|
|
|
log.Info("query collaborationList size=" + fmt.Sprint(len(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] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
userMapJson, _ := json.Marshal(userMap) |
|
|
|
log.Info("userMapJson=" + string(userMapJson)) |
|
|
|
|
|
|
|
return userMap |
|
|
|
} |
|
|
|
|
|
|
|
func queryLoginCount(start_unix int64, end_unix int64) map[int64]int { |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|