|
|
|
@@ -106,7 +106,8 @@ type UserBusinessAnalysisAll struct { |
|
|
|
CollectedImage int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
RecommendImage int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
|
|
Phone string `xorm:"NULL"` |
|
|
|
Phone string `xorm:"NULL"` |
|
|
|
InvitationUserNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
} |
|
|
|
|
|
|
|
type UserBusinessAnalysis struct { |
|
|
|
@@ -193,7 +194,8 @@ type UserBusinessAnalysis struct { |
|
|
|
CollectedImage int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
RecommendImage int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
|
|
Phone string `xorm:"NULL"` |
|
|
|
Phone string `xorm:"NULL"` |
|
|
|
InvitationUserNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
} |
|
|
|
|
|
|
|
type UserBusinessAnalysisQueryOptions struct { |
|
|
|
@@ -354,6 +356,33 @@ func QueryRankList(key string, tableName string, limit int) ([]*UserBusinessAnal |
|
|
|
return userBusinessAnalysisAllList, int64(len(userBusinessAnalysisAllList)) |
|
|
|
} |
|
|
|
|
|
|
|
func QueryUserInvitationDataByTableName(start int, pageSize int, tableName string, queryObj interface{}, userName string, invitationNum int) ([]*UserBusinessAnalysisAll, int64) { |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
var cond = builder.NewCond() |
|
|
|
if len(userName) > 0 { |
|
|
|
cond = cond.And( |
|
|
|
builder.Like{"lower(name)", strings.ToLower(userName)}, |
|
|
|
) |
|
|
|
} |
|
|
|
cond = cond.And( |
|
|
|
builder.Gte{"invitation_user_num": invitationNum}, |
|
|
|
) |
|
|
|
|
|
|
|
allCount, err := statictisSess.Where(cond).Count(queryObj) |
|
|
|
if err != nil { |
|
|
|
log.Info("query error." + err.Error()) |
|
|
|
return nil, 0 |
|
|
|
} |
|
|
|
log.Info("query return total:" + fmt.Sprint(allCount)) |
|
|
|
userBusinessAnalysisAllList := make([]*UserBusinessAnalysisAll, 0) |
|
|
|
if err := statictisSess.Table(tableName).Where(cond).OrderBy("invitation_user_num desc,id asc").Limit(pageSize, start). |
|
|
|
Find(&userBusinessAnalysisAllList); err != nil { |
|
|
|
return nil, 0 |
|
|
|
} |
|
|
|
return userBusinessAnalysisAllList, allCount |
|
|
|
} |
|
|
|
|
|
|
|
func QueryUserStaticDataByTableName(start int, pageSize int, tableName string, queryObj interface{}, userName string) ([]*UserBusinessAnalysisAll, int64) { |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
@@ -363,6 +392,7 @@ func QueryUserStaticDataByTableName(start int, pageSize int, tableName string, q |
|
|
|
builder.Like{"lower(name)", strings.ToLower(userName)}, |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
allCount, err := statictisSess.Where(cond).Count(queryObj) |
|
|
|
if err != nil { |
|
|
|
log.Info("query error." + err.Error()) |
|
|
|
@@ -752,6 +782,8 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
|
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" |
|
|
|
|
|
|
|
cond := "type != 1 and is_active=true" |
|
|
|
@@ -825,7 +857,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
|
dateRecordAll.CollectImage = getMapValue(dateRecordAll.ID, CollectImage) |
|
|
|
dateRecordAll.CollectedImage = getMapValue(dateRecordAll.ID, CollectedImage) |
|
|
|
dateRecordAll.RecommendImage = getMapValue(dateRecordAll.ID, RecommendImage) |
|
|
|
|
|
|
|
dateRecordAll.InvitationUserNum = getMapValue(dateRecordAll.ID, InvitationMap) |
|
|
|
dateRecordAll.UserIndexPrimitive = getUserIndexFromAnalysisAll(dateRecordAll, ParaWeight) |
|
|
|
userIndexMap[dateRecordAll.ID] = dateRecordAll.UserIndexPrimitive |
|
|
|
if maxUserIndex < dateRecordAll.UserIndexPrimitive { |
|
|
|
@@ -888,7 +920,7 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static |
|
|
|
|
|
|
|
insertBatchSql := "INSERT INTO public." + tableName + |
|
|
|
"(id, count_date, code_merge_count, commit_count, issue_count, comment_count, focus_repo_count, star_repo_count, watched_count, gitea_age_month, commit_code_size, commit_dataset_size, " + |
|
|
|
"commit_model_count, solve_issue_count, encyclopedias_count, regist_date, create_repo_count, login_count, open_i_index, email, name, data_date,cloud_brain_task_num,gpu_debug_job,npu_debug_job,gpu_train_job,npu_train_job,npu_inference_job,gpu_bench_mark_job,cloud_brain_run_time,commit_dataset_num,user_index,user_location,focus_other_user,collect_dataset,collected_dataset,recommend_dataset,collect_image,collected_image,recommend_image,user_index_primitive,phone) " + |
|
|
|
"commit_model_count, solve_issue_count, encyclopedias_count, regist_date, create_repo_count, login_count, open_i_index, email, name, data_date,cloud_brain_task_num,gpu_debug_job,npu_debug_job,gpu_train_job,npu_train_job,npu_inference_job,gpu_bench_mark_job,cloud_brain_run_time,commit_dataset_num,user_index,user_location,focus_other_user,collect_dataset,collected_dataset,recommend_dataset,collect_image,collected_image,recommend_image,user_index_primitive,phone,invitation_user_num) " + |
|
|
|
"VALUES" |
|
|
|
|
|
|
|
for i, record := range dateRecords { |
|
|
|
@@ -897,7 +929,7 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static |
|
|
|
", " + fmt.Sprint(record.WatchedCount) + ", " + fmt.Sprint(record.GiteaAgeMonth) + ", " + fmt.Sprint(record.CommitCodeSize) + ", " + fmt.Sprint(record.CommitDatasetSize) + |
|
|
|
", " + fmt.Sprint(record.CommitModelCount) + ", " + fmt.Sprint(record.SolveIssueCount) + ", " + fmt.Sprint(record.EncyclopediasCount) + ", " + fmt.Sprint(record.RegistDate) + |
|
|
|
", " + fmt.Sprint(record.CreateRepoCount) + ", " + fmt.Sprint(record.LoginCount) + ", " + fmt.Sprint(record.OpenIIndex) + ", '" + record.Email + "', '" + record.Name + "', '" + record.DataDate + "'," + fmt.Sprint(record.CloudBrainTaskNum) + "," + fmt.Sprint(record.GpuDebugJob) + "," + fmt.Sprint(record.NpuDebugJob) + "," + fmt.Sprint(record.GpuTrainJob) + "," + fmt.Sprint(record.NpuTrainJob) + "," + fmt.Sprint(record.NpuInferenceJob) + "," + fmt.Sprint(record.GpuBenchMarkJob) + "," + fmt.Sprint(record.CloudBrainRunTime) + "," + fmt.Sprint(record.CommitDatasetNum) + "," + fmt.Sprint(record.UserIndex) + ",'" + record.UserLocation + "'," + |
|
|
|
fmt.Sprint(record.FocusOtherUser) + "," + fmt.Sprint(record.CollectDataset) + "," + fmt.Sprint(record.CollectedDataset) + "," + fmt.Sprint(record.RecommendDataset) + "," + fmt.Sprint(record.CollectImage) + "," + fmt.Sprint(record.CollectedImage) + "," + fmt.Sprint(record.RecommendImage) + "," + fmt.Sprint(record.UserIndexPrimitive) + ",'" + record.Phone + "')" |
|
|
|
fmt.Sprint(record.FocusOtherUser) + "," + fmt.Sprint(record.CollectDataset) + "," + fmt.Sprint(record.CollectedDataset) + "," + fmt.Sprint(record.RecommendDataset) + "," + fmt.Sprint(record.CollectImage) + "," + fmt.Sprint(record.CollectedImage) + "," + fmt.Sprint(record.RecommendImage) + "," + fmt.Sprint(record.UserIndexPrimitive) + ",'" + record.Phone + "'" + "," + fmt.Sprint(record.InvitationUserNum) + ")" |
|
|
|
if i < (len(dateRecords) - 1) { |
|
|
|
insertBatchSql += "," |
|
|
|
} |
|
|
|
@@ -2173,6 +2205,41 @@ func queryCloudBrainTask(start_unix int64, end_unix int64) (map[int64]int, map[s |
|
|
|
|
|
|
|
return resultMap, resultItemMap |
|
|
|
} |
|
|
|
|
|
|
|
func queryUserInvitationCount(start_unix int64, end_unix int64) map[int64]int { |
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
|
defer statictisSess.Close() |
|
|
|
|
|
|
|
resultMap := make(map[int64]int) |
|
|
|
cond := "created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) |
|
|
|
count, err := statictisSess.Where(cond).Count(new(Invitation)) |
|
|
|
if err != nil { |
|
|
|
log.Info("query queryUserInvitationCount error. return.") |
|
|
|
return resultMap |
|
|
|
} |
|
|
|
var indexTotal int64 |
|
|
|
indexTotal = 0 |
|
|
|
for { |
|
|
|
statictisSess.Select("id,src_user_id,user_id").Table("invitation").Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) |
|
|
|
invitationList := make([]*Invitation, 0) |
|
|
|
statictisSess.Find(&invitationList) |
|
|
|
log.Info("query invitationList size=" + fmt.Sprint(len(invitationList))) |
|
|
|
for _, invitationRecord := range invitationList { |
|
|
|
if _, ok := resultMap[invitationRecord.SrcUserID]; !ok { |
|
|
|
resultMap[invitationRecord.SrcUserID] = 1 |
|
|
|
} else { |
|
|
|
resultMap[invitationRecord.SrcUserID] += 1 |
|
|
|
} |
|
|
|
} |
|
|
|
indexTotal += PAGE_SIZE |
|
|
|
if indexTotal >= count { |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
log.Info("invitationList size=" + fmt.Sprint(len(resultMap))) |
|
|
|
return resultMap |
|
|
|
} |
|
|
|
|
|
|
|
func setMapKey(key string, userId int64, value int, resultItemMap map[string]int) { |
|
|
|
newKey := fmt.Sprint(userId) + "_" + key |
|
|
|
if _, ok := resultItemMap[newKey]; !ok { |
|
|
|
|