|
|
@@ -586,7 +586,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
|
startTime := currentTimeNow.AddDate(0, 0, -1) |
|
|
|
|
|
|
|
CodeMergeCountMap := queryPullRequest(start_unix, end_unix) |
|
|
|
CommitCountMap, mostActiveMap := queryCommitAction(start_unix, end_unix, 5) |
|
|
|
CommitCountMap, _ := queryCommitAction(start_unix, end_unix, 5) |
|
|
|
IssueCountMap := queryCreateIssue(start_unix, end_unix) |
|
|
|
|
|
|
|
CommentCountMap := queryComment(start_unix, end_unix) |
|
|
@@ -602,9 +602,9 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
|
//log.Info("CommitCodeSizeMapJson=" + string(CommitCodeSizeMapJson)) |
|
|
|
} |
|
|
|
//CommitCodeSizeMap := queryCommitCodeSize(StartTimeNextDay.Unix(), EndTimeNextDay.Unix()) |
|
|
|
CommitDatasetSizeMap, CommitDatasetNumMap, dataSetDownloadMap := queryDatasetSize(start_unix, end_unix) |
|
|
|
CommitDatasetSizeMap, CommitDatasetNumMap, _ := queryDatasetSize(start_unix, end_unix) |
|
|
|
SolveIssueCountMap := querySolveIssue(start_unix, end_unix) |
|
|
|
CreateRepoCountMap, DetailInfoMap, MostDownloadMap := queryUserCreateRepo(start_unix, end_unix) |
|
|
|
CreateRepoCountMap, _, _ := queryUserCreateRepo(start_unix, end_unix) |
|
|
|
LoginCountMap := queryLoginCount(start_unix, end_unix) |
|
|
|
|
|
|
|
OpenIIndexMap := queryUserRepoOpenIIndex(startTime.Unix(), end_unix) |
|
|
@@ -613,19 +613,14 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
|
AiModelConvertMap := queryUserModelConvert(start_unix, end_unix) |
|
|
|
|
|
|
|
CollectDataset, CollectedDataset := queryDatasetStars(start_unix, end_unix) |
|
|
|
RecommendDataset, CreatedDataset := queryRecommedDataSet(start_unix, end_unix) |
|
|
|
RecommendDataset, _ := queryRecommedDataSet(start_unix, end_unix) |
|
|
|
CollectImage, CollectedImage := queryImageStars(start_unix, end_unix) |
|
|
|
RecommendImage := queryRecommedImage(start_unix, end_unix) |
|
|
|
|
|
|
|
InvitationMap := queryUserInvitationCount(start_unix, end_unix) |
|
|
|
|
|
|
|
DataDate := currentTimeNow.Format("2006-01-02") + " 00:01" |
|
|
|
bonusMap := make(map[string]map[string]int) |
|
|
|
if isUserYearData(tableName) { |
|
|
|
bonusMap = getBonusMap() |
|
|
|
log.Info("truncate all data from table:user_summary_current_year ") |
|
|
|
statictisSess.Exec("TRUNCATE TABLE user_summary_current_year") |
|
|
|
} |
|
|
|
|
|
|
|
cond := "type != 1 and is_active=true" |
|
|
|
count, err := sess.Where(cond).Count(new(User)) |
|
|
|
if err != nil { |
|
|
@@ -724,37 +719,6 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
|
userMetrics["TotalHasActivityUser"] = getMapKeyStringValue("TotalHasActivityUser", userMetrics) + 1 |
|
|
|
} |
|
|
|
} |
|
|
|
if isUserYearData(tableName) { |
|
|
|
//年度数据 |
|
|
|
subTime := time.Now().UTC().Sub(dateRecordAll.RegistDate.AsTime().UTC()) |
|
|
|
mostActiveDay := "" |
|
|
|
if userInfo, ok := mostActiveMap[dateRecordAll.ID]; ok { |
|
|
|
mostActiveDay = getMostActiveJson(userInfo) |
|
|
|
} |
|
|
|
scoreMap := make(map[string]float64) |
|
|
|
repoInfo := getRepoDetailInfo(DetailInfoMap, dateRecordAll.ID, MostDownloadMap) |
|
|
|
dataSetInfo, datasetscore := getDataSetInfo(dateRecordAll.ID, CreatedDataset, dataSetDownloadMap, CommitDatasetNumMap, CollectedDataset) |
|
|
|
scoreMap["datasetscore"] = datasetscore |
|
|
|
codeInfo, codescore := getCodeInfo(dateRecordAll) |
|
|
|
scoreMap["codescore"] = codescore |
|
|
|
cloudBrainInfo := getCloudBrainInfo(dateRecordAll, CloudBrainTaskItemMap, scoreMap) |
|
|
|
playARoll := getPlayARoll(bonusMap, dateRecordAll.Name, scoreMap) |
|
|
|
re := &UserSummaryCurrentYear{ |
|
|
|
ID: dateRecordAll.ID, |
|
|
|
Name: dateRecordAll.Name, |
|
|
|
Email: dateRecordAll.Email, |
|
|
|
Phone: dateRecordAll.Phone, |
|
|
|
RegistDate: dateRecordAll.RegistDate, |
|
|
|
DateCount: int(subTime.Hours()) / 24, |
|
|
|
MostActiveDay: mostActiveDay, |
|
|
|
RepoInfo: repoInfo, |
|
|
|
DataSetInfo: dataSetInfo, |
|
|
|
CodeInfo: codeInfo, |
|
|
|
CloudBrainInfo: cloudBrainInfo, |
|
|
|
PlayARoll: playARoll, |
|
|
|
} |
|
|
|
statictisSess.Insert(re) |
|
|
|
} |
|
|
|
} |
|
|
|
if len(dateRecordBatch) > 0 { |
|
|
|
err := insertTable(dateRecordBatch, tableName, statictisSess) |
|
|
@@ -784,6 +748,127 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
|
log.Info("refresh data finished.tableName=" + tableName + " total record:" + fmt.Sprint(insertCount)) |
|
|
|
} |
|
|
|
|
|
|
|
func RefreshUserYearTable(pageStartTime time.Time, pageEndTime time.Time) { |
|
|
|
sess := x.NewSession() |
|
|
|
defer sess.Close() |
|
|
|
log.Info("RefreshUserYearTable start....") |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
|
|
|
|
log.Info("UserYear StartTime:" + pageStartTime.Format("2006-01-02 15:04:05")) |
|
|
|
log.Info("UserYear EndTime time:" + pageEndTime.Format("2006-01-02 15:04:05")) |
|
|
|
|
|
|
|
start_unix := pageStartTime.Unix() |
|
|
|
end_unix := pageEndTime.Unix() |
|
|
|
|
|
|
|
CodeMergeCountMap := queryPullRequest(start_unix, end_unix) |
|
|
|
CommitCountMap, mostActiveMap := queryCommitAction(start_unix, end_unix, 5) |
|
|
|
IssueCountMap := queryCreateIssue(start_unix, end_unix) |
|
|
|
|
|
|
|
CommentCountMap := queryComment(start_unix, end_unix) |
|
|
|
|
|
|
|
CommitCodeSizeMap, err := GetAllUserKPIStats(pageStartTime, pageEndTime) |
|
|
|
if err != nil { |
|
|
|
log.Info("query commit code errr.") |
|
|
|
} else { |
|
|
|
log.Info("query commit code size, len=" + fmt.Sprint(len(CommitCodeSizeMap))) |
|
|
|
} |
|
|
|
CommitDatasetSizeMap, CommitDatasetNumMap, dataSetDownloadMap := queryDatasetSize(start_unix, end_unix) |
|
|
|
SolveIssueCountMap := querySolveIssue(start_unix, end_unix) |
|
|
|
CreateRepoCountMap, DetailInfoMap, MostDownloadMap := queryUserCreateRepo(start_unix, end_unix) |
|
|
|
|
|
|
|
CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) |
|
|
|
|
|
|
|
_, CollectedDataset := queryDatasetStars(start_unix, end_unix) |
|
|
|
_, CreatedDataset := queryRecommedDataSet(start_unix, end_unix) |
|
|
|
|
|
|
|
bonusMap := getBonusMap() |
|
|
|
log.Info("truncate all data from table:user_summary_current_year ") |
|
|
|
statictisSess.Exec("TRUNCATE TABLE user_summary_current_year") |
|
|
|
|
|
|
|
cond := "type != 1 and is_active=true" |
|
|
|
count, err := sess.Where(cond).Count(new(User)) |
|
|
|
if err != nil { |
|
|
|
log.Info("query user error. return.") |
|
|
|
return |
|
|
|
} |
|
|
|
var indexTotal int64 |
|
|
|
indexTotal = 0 |
|
|
|
for { |
|
|
|
sess.Select("`user`.*").Table("user").Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) |
|
|
|
userList := make([]*User, 0) |
|
|
|
sess.Find(&userList) |
|
|
|
for _, userRecord := range userList { |
|
|
|
var dateRecordAll UserBusinessAnalysisAll |
|
|
|
dateRecordAll.ID = userRecord.ID |
|
|
|
dateRecordAll.Email = userRecord.Email |
|
|
|
dateRecordAll.Phone = userRecord.PhoneNumber |
|
|
|
dateRecordAll.RegistDate = userRecord.CreatedUnix |
|
|
|
dateRecordAll.Name = userRecord.Name |
|
|
|
|
|
|
|
dateRecordAll.CodeMergeCount = getMapValue(dateRecordAll.ID, CodeMergeCountMap) |
|
|
|
dateRecordAll.CommitCount = getMapValue(dateRecordAll.ID, CommitCountMap) |
|
|
|
dateRecordAll.IssueCount = getMapValue(dateRecordAll.ID, IssueCountMap) |
|
|
|
dateRecordAll.CommentCount = getMapValue(dateRecordAll.ID, CommentCountMap) |
|
|
|
|
|
|
|
if _, ok := CommitCodeSizeMap[dateRecordAll.Email]; !ok { |
|
|
|
dateRecordAll.CommitCodeSize = 0 |
|
|
|
} else { |
|
|
|
dateRecordAll.CommitCodeSize = int(CommitCodeSizeMap[dateRecordAll.Email].CommitLines) |
|
|
|
} |
|
|
|
//dateRecordAll.CommitCodeSize = getMapValue(dateRecordAll.ID, CommitCodeSizeMap) |
|
|
|
dateRecordAll.CommitDatasetSize = getMapValue(dateRecordAll.ID, CommitDatasetSizeMap) |
|
|
|
dateRecordAll.CommitDatasetNum = getMapValue(dateRecordAll.ID, CommitDatasetNumMap) |
|
|
|
dateRecordAll.SolveIssueCount = getMapValue(dateRecordAll.ID, SolveIssueCountMap) |
|
|
|
dateRecordAll.CreateRepoCount = getMapValue(dateRecordAll.ID, CreateRepoCountMap) |
|
|
|
|
|
|
|
dateRecordAll.CloudBrainTaskNum = getMapValue(dateRecordAll.ID, CloudBrainTaskMap) |
|
|
|
dateRecordAll.GpuDebugJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuDebugJob", CloudBrainTaskItemMap) |
|
|
|
dateRecordAll.NpuDebugJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuDebugJob", CloudBrainTaskItemMap) |
|
|
|
dateRecordAll.GpuTrainJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuTrainJob", CloudBrainTaskItemMap) |
|
|
|
dateRecordAll.NpuTrainJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuTrainJob", CloudBrainTaskItemMap) |
|
|
|
dateRecordAll.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) |
|
|
|
dateRecordAll.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) |
|
|
|
dateRecordAll.CloudBrainRunTime = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_CloudBrainRunTime", CloudBrainTaskItemMap) |
|
|
|
|
|
|
|
//年度数据 |
|
|
|
subTime := time.Now().UTC().Sub(dateRecordAll.RegistDate.AsTime().UTC()) |
|
|
|
mostActiveDay := "" |
|
|
|
if userInfo, ok := mostActiveMap[dateRecordAll.ID]; ok { |
|
|
|
mostActiveDay = getMostActiveJson(userInfo) |
|
|
|
} |
|
|
|
scoreMap := make(map[string]float64) |
|
|
|
repoInfo := getRepoDetailInfo(DetailInfoMap, dateRecordAll.ID, MostDownloadMap) |
|
|
|
dataSetInfo, datasetscore := getDataSetInfo(dateRecordAll.ID, CreatedDataset, dataSetDownloadMap, CommitDatasetNumMap, CollectedDataset) |
|
|
|
scoreMap["datasetscore"] = datasetscore |
|
|
|
codeInfo, codescore := getCodeInfo(dateRecordAll) |
|
|
|
scoreMap["codescore"] = codescore |
|
|
|
cloudBrainInfo := getCloudBrainInfo(dateRecordAll, CloudBrainTaskItemMap, scoreMap) |
|
|
|
playARoll := getPlayARoll(bonusMap, dateRecordAll.Name, scoreMap) |
|
|
|
re := &UserSummaryCurrentYear{ |
|
|
|
ID: dateRecordAll.ID, |
|
|
|
Name: dateRecordAll.Name, |
|
|
|
Email: dateRecordAll.Email, |
|
|
|
Phone: dateRecordAll.Phone, |
|
|
|
RegistDate: dateRecordAll.RegistDate, |
|
|
|
DateCount: int(subTime.Hours()) / 24, |
|
|
|
MostActiveDay: mostActiveDay, |
|
|
|
RepoInfo: repoInfo, |
|
|
|
DataSetInfo: dataSetInfo, |
|
|
|
CodeInfo: codeInfo, |
|
|
|
CloudBrainInfo: cloudBrainInfo, |
|
|
|
PlayARoll: playARoll, |
|
|
|
} |
|
|
|
statictisSess.Insert(re) |
|
|
|
} |
|
|
|
indexTotal += PAGE_SIZE |
|
|
|
if indexTotal >= count { |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
log.Info("update user year data finished. ") |
|
|
|
} |
|
|
|
|
|
|
|
func isUserYearData(tableName string) bool { |
|
|
|
if tableName == "user_business_analysis_current_year" { |
|
|
|
currentTimeNow := time.Now() |
|
|
@@ -1504,10 +1589,6 @@ func getInt(str string) int { |
|
|
|
return int(re) |
|
|
|
} |
|
|
|
|
|
|
|
func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime time.Time) { |
|
|
|
CounDataByDateAndReCount(wikiCountMap, startTime, endTime, false) |
|
|
|
} |
|
|
|
|
|
|
|
func querySolveIssue(start_unix int64, end_unix int64) map[int64]int { |
|
|
|
sess := x.NewSession() |
|
|
|
defer sess.Close() |
|
|
|