|
@@ -1,7 +1,6 @@ |
|
|
package models |
|
|
package models |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"encoding/json" |
|
|
|
|
|
"fmt" |
|
|
"fmt" |
|
|
"sort" |
|
|
"sort" |
|
|
"strconv" |
|
|
"strconv" |
|
@@ -202,15 +201,7 @@ func QueryUserStaticDataAll(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusi |
|
|
return nil, 0 |
|
|
return nil, 0 |
|
|
} |
|
|
} |
|
|
log.Info("query return total:" + fmt.Sprint(allCount)) |
|
|
log.Info("query return total:" + fmt.Sprint(allCount)) |
|
|
if allCount == 0 { |
|
|
|
|
|
CommitCodeSizeMap, err := GetAllUserKPIStats() |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Info("query commit code errr.") |
|
|
|
|
|
} else { |
|
|
|
|
|
log.Info("query commit code size, len=" + fmt.Sprint(len(CommitCodeSizeMap))) |
|
|
|
|
|
} |
|
|
|
|
|
RefreshUserStaticAllTabel(make(map[string]int), CommitCodeSizeMap) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pageSize := 1000 |
|
|
pageSize := 1000 |
|
|
totalPage := int(allCount) / pageSize |
|
|
totalPage := int(allCount) / pageSize |
|
|
userBusinessAnalysisReturnList := UserBusinessAnalysisAllList{} |
|
|
userBusinessAnalysisReturnList := UserBusinessAnalysisAllList{} |
|
@@ -370,7 +361,7 @@ func RefreshUserStaticAllTabel(wikiCountMap map[string]int, CommitCodeSizeMap ma |
|
|
|
|
|
|
|
|
CodeMergeCountMap := queryPullRequest(start_unix, end_unix) |
|
|
CodeMergeCountMap := queryPullRequest(start_unix, end_unix) |
|
|
CommitCountMap := queryCommitAction(start_unix, end_unix, 5) |
|
|
CommitCountMap := queryCommitAction(start_unix, end_unix, 5) |
|
|
IssueCountMap := queryAction(start_unix, end_unix, 6) |
|
|
|
|
|
|
|
|
IssueCountMap := queryCreateIssue(start_unix, end_unix) |
|
|
|
|
|
|
|
|
CommentCountMap := queryComment(start_unix, end_unix) |
|
|
CommentCountMap := queryComment(start_unix, end_unix) |
|
|
FocusRepoCountMap := queryWatch(start_unix, end_unix) |
|
|
FocusRepoCountMap := queryWatch(start_unix, end_unix) |
|
@@ -395,7 +386,7 @@ func RefreshUserStaticAllTabel(wikiCountMap map[string]int, CommitCodeSizeMap ma |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
sess.Select("`user`.*").Table("user").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Select("`user`.*").Table("user").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
userList := make([]*User, 0) |
|
|
userList := make([]*User, 0) |
|
|
sess.Find(&userList) |
|
|
sess.Find(&userList) |
|
|
for i, userRecord := range userList { |
|
|
for i, userRecord := range userList { |
|
@@ -528,7 +519,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
DataDate := startTime.Format("2006-01-02") |
|
|
DataDate := startTime.Format("2006-01-02") |
|
|
CodeMergeCountMap := queryPullRequest(start_unix, end_unix) |
|
|
CodeMergeCountMap := queryPullRequest(start_unix, end_unix) |
|
|
CommitCountMap := queryCommitAction(start_unix, end_unix, 5) |
|
|
CommitCountMap := queryCommitAction(start_unix, end_unix, 5) |
|
|
IssueCountMap := queryAction(start_unix, end_unix, 6) |
|
|
|
|
|
|
|
|
IssueCountMap := queryCreateIssue(start_unix, end_unix) |
|
|
|
|
|
|
|
|
CommentCountMap := queryComment(start_unix, end_unix) |
|
|
CommentCountMap := queryComment(start_unix, end_unix) |
|
|
FocusRepoCountMap := queryWatch(start_unix, end_unix) |
|
|
FocusRepoCountMap := queryWatch(start_unix, end_unix) |
|
@@ -559,7 +550,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
sess.Select("`user`.*").Table("user").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Select("`user`.*").Table("user").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
userList := make([]*User, 0) |
|
|
userList := make([]*User, 0) |
|
|
sess.Find(&userList) |
|
|
sess.Find(&userList) |
|
|
|
|
|
|
|
@@ -709,7 +700,7 @@ func querySolveIssue(start_unix int64, end_unix int64) map[int64]int { |
|
|
issueAssigneesList := make([]*IssueAssignees, 0) |
|
|
issueAssigneesList := make([]*IssueAssignees, 0) |
|
|
sess.Select("issue_assignees.*").Table("issue_assignees"). |
|
|
sess.Select("issue_assignees.*").Table("issue_assignees"). |
|
|
Join("inner", "issue", "issue.id=issue_assignees.issue_id"). |
|
|
Join("inner", "issue", "issue.id=issue_assignees.issue_id"). |
|
|
Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
Where(cond).OrderBy("issue_assignees.id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Find(&issueAssigneesList) |
|
|
sess.Find(&issueAssigneesList) |
|
|
|
|
|
|
|
@@ -744,7 +735,7 @@ func queryPullRequest(start_unix int64, end_unix int64) map[int64]int { |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
issueList := make([]*Issue, 0) |
|
|
issueList := make([]*Issue, 0) |
|
|
sess.Select("issue.*").Table("issue").Join("inner", "pull_request", "issue.id=pull_request.issue_id").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Select("issue.*").Table("issue").Join("inner", "pull_request", "issue.id=pull_request.issue_id").Where(cond).OrderBy("issue.id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
sess.Find(&issueList) |
|
|
sess.Find(&issueList) |
|
|
log.Info("query issue(PR) size=" + fmt.Sprint(len(issueList))) |
|
|
log.Info("query issue(PR) size=" + fmt.Sprint(len(issueList))) |
|
|
for _, issueRecord := range issueList { |
|
|
for _, issueRecord := range issueList { |
|
@@ -777,7 +768,7 @@ func queryCommitAction(start_unix int64, end_unix int64, actionType int64) map[i |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
sess.Select("id,user_id,op_type,act_user_id").Table("action").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Select("id,user_id,op_type,act_user_id").Table("action").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
actionList := make([]*Action, 0) |
|
|
actionList := make([]*Action, 0) |
|
|
sess.Find(&actionList) |
|
|
sess.Find(&actionList) |
|
|
|
|
|
|
|
@@ -799,29 +790,30 @@ func queryCommitAction(start_unix int64, end_unix int64, actionType int64) map[i |
|
|
return resultMap |
|
|
return resultMap |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func queryAction(start_unix int64, end_unix int64, actionType int64) map[int64]int { |
|
|
|
|
|
|
|
|
func queryCreateIssue(start_unix int64, end_unix int64) map[int64]int { |
|
|
|
|
|
|
|
|
sess := x.NewSession() |
|
|
sess := x.NewSession() |
|
|
defer sess.Close() |
|
|
defer sess.Close() |
|
|
resultMap := make(map[int64]int) |
|
|
resultMap := make(map[int64]int) |
|
|
cond := "op_type=" + fmt.Sprint(actionType) + " and created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) |
|
|
|
|
|
|
|
|
cond := "is_pull=false and created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) |
|
|
|
|
|
|
|
|
count, err := sess.Where(cond).Count(new(Action)) |
|
|
|
|
|
|
|
|
count, err := sess.Where(cond).Count(new(Issue)) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Info("query Action error. return.") |
|
|
|
|
|
|
|
|
log.Info("query Issue error. return.") |
|
|
return resultMap |
|
|
return resultMap |
|
|
} |
|
|
} |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
sess.Select("id,user_id,op_type,act_user_id").Table("action").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
actionList := make([]*Action, 0) |
|
|
|
|
|
sess.Find(&actionList) |
|
|
|
|
|
log.Info("query action size=" + fmt.Sprint(len(actionList))) |
|
|
|
|
|
for _, actionRecord := range actionList { |
|
|
|
|
|
if _, ok := resultMap[actionRecord.UserID]; !ok { |
|
|
|
|
|
resultMap[actionRecord.UserID] = 1 |
|
|
|
|
|
|
|
|
sess.Select("id,poster_id").Table("issue").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
issueList := make([]*Issue, 0) |
|
|
|
|
|
sess.Find(&issueList) |
|
|
|
|
|
log.Info("query issue size=" + fmt.Sprint(len(issueList))) |
|
|
|
|
|
for _, issueRecord := range issueList { |
|
|
|
|
|
if _, ok := resultMap[issueRecord.PosterID]; !ok { |
|
|
|
|
|
resultMap[issueRecord.PosterID] = 1 |
|
|
} else { |
|
|
} else { |
|
|
resultMap[actionRecord.UserID] += 1 |
|
|
|
|
|
|
|
|
resultMap[issueRecord.PosterID] += 1 |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
indexTotal += Page_SIZE |
|
|
indexTotal += Page_SIZE |
|
@@ -830,6 +822,7 @@ func queryAction(start_unix int64, end_unix int64, actionType int64) map[int64]i |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return resultMap |
|
|
return resultMap |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func queryComment(start_unix int64, end_unix int64) map[int64]int { |
|
|
func queryComment(start_unix int64, end_unix int64) map[int64]int { |
|
@@ -846,7 +839,7 @@ func queryComment(start_unix int64, end_unix int64) map[int64]int { |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
sess.Select("id,type,poster_id").Table("comment").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Select("id,type,poster_id").Table("comment").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
commentList := make([]*Comment, 0) |
|
|
commentList := make([]*Comment, 0) |
|
|
sess.Find(&commentList) |
|
|
sess.Find(&commentList) |
|
|
log.Info("query Comment size=" + fmt.Sprint(len(commentList))) |
|
|
log.Info("query Comment size=" + fmt.Sprint(len(commentList))) |
|
@@ -882,7 +875,7 @@ func queryWatch(start_unix int64, end_unix int64) map[int64]int { |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
watchList := make([]*Watch, 0) |
|
|
watchList := make([]*Watch, 0) |
|
|
sess.Select("id,user_id,repo_id").Table("watch").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Select("id,user_id,repo_id").Table("watch").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
sess.Find(&watchList) |
|
|
sess.Find(&watchList) |
|
|
|
|
|
|
|
|
log.Info("query Watch size=" + fmt.Sprint(len(watchList))) |
|
|
log.Info("query Watch size=" + fmt.Sprint(len(watchList))) |
|
@@ -920,7 +913,7 @@ func queryStar(start_unix int64, end_unix int64) map[int64]int { |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
sess.Select("id,uid,repo_id").Table("star").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Select("id,uid,repo_id").Table("star").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
starList := make([]*Star, 0) |
|
|
starList := make([]*Star, 0) |
|
|
sess.Find(&starList) |
|
|
sess.Find(&starList) |
|
|
|
|
|
|
|
@@ -956,7 +949,7 @@ func queryFollow(start_unix int64, end_unix int64) map[int64]int { |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
sess.Select("id,user_id,follow_id").Table("follow").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Select("id,user_id,follow_id").Table("follow").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
followList := make([]*Follow, 0) |
|
|
followList := make([]*Follow, 0) |
|
|
sess.Find(&followList) |
|
|
sess.Find(&followList) |
|
|
|
|
|
|
|
@@ -992,7 +985,7 @@ func queryDatasetSize(start_unix int64, end_unix int64) map[int64]int { |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
sess.Select("id,uploader_id,size").Table("attachment").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Select("id,uploader_id,size").Table("attachment").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
attachmentList := make([]*Attachment, 0) |
|
|
attachmentList := make([]*Attachment, 0) |
|
|
sess.Find(&attachmentList) |
|
|
sess.Find(&attachmentList) |
|
|
|
|
|
|
|
@@ -1028,7 +1021,7 @@ func queryUserCreateRepo(start_unix int64, end_unix int64) map[int64]int { |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
sess.Select("id,owner_id,name").Table("repository").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
sess.Select("id,owner_id,name").Table("repository").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
repoList := make([]*Repository, 0) |
|
|
repoList := make([]*Repository, 0) |
|
|
sess.Find(&repoList) |
|
|
sess.Find(&repoList) |
|
|
log.Info("query Repository size=" + fmt.Sprint(len(repoList))) |
|
|
log.Info("query Repository size=" + fmt.Sprint(len(repoList))) |
|
@@ -1099,8 +1092,7 @@ func queryUserRepoOpenIIndex(start_unix int64, end_unix int64) map[int64]float64 |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
userMapJson, _ := json.Marshal(userMap) |
|
|
|
|
|
log.Info("userMapJson=" + string(userMapJson)) |
|
|
|
|
|
|
|
|
log.Info("user openi index size=" + fmt.Sprint(len(userMap))) |
|
|
|
|
|
|
|
|
return userMap |
|
|
return userMap |
|
|
} |
|
|
} |
|
@@ -1119,7 +1111,7 @@ func queryLoginCount(start_unix int64, end_unix int64) map[int64]int { |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
|
for { |
|
|
for { |
|
|
statictisSess.Select("id,u_id").Table("user_login_log").Where(cond).Limit(Page_SIZE, int(indexTotal)) |
|
|
|
|
|
|
|
|
statictisSess.Select("id,u_id").Table("user_login_log").Where(cond).OrderBy("id asc").Limit(Page_SIZE, int(indexTotal)) |
|
|
userLoginLogList := make([]*UserLoginLog, 0) |
|
|
userLoginLogList := make([]*UserLoginLog, 0) |
|
|
statictisSess.Find(&userLoginLogList) |
|
|
statictisSess.Find(&userLoginLogList) |
|
|
log.Info("query user login size=" + fmt.Sprint(len(userLoginLogList))) |
|
|
log.Info("query user login size=" + fmt.Sprint(len(userLoginLogList))) |
|
@@ -1135,7 +1127,7 @@ func queryLoginCount(start_unix int64, end_unix int64) map[int64]int { |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
log.Info("user login size=" + fmt.Sprint(len(resultMap))) |
|
|
return resultMap |
|
|
return resultMap |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|