|
@@ -82,17 +82,27 @@ type UserBusinessAnalysisAll struct { |
|
|
DataDate string `xorm:"NULL"` |
|
|
DataDate string `xorm:"NULL"` |
|
|
|
|
|
|
|
|
//cloudbraintask |
|
|
//cloudbraintask |
|
|
CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
UserLocation string `xorm:"NULL"` |
|
|
|
|
|
|
|
|
CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
UserIndexPrimitive float64 `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
|
|
|
|
|
|
UserLocation string `xorm:"NULL"` |
|
|
|
|
|
|
|
|
|
|
|
FocusOtherUser int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CollectDataset int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CollectedDataset int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
RecommendDataset int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CollectImage int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CollectedImage int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
RecommendImage int `xorm:"NOT NULL DEFAULT 0"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type UserBusinessAnalysis struct { |
|
|
type UserBusinessAnalysis struct { |
|
@@ -159,17 +169,27 @@ type UserBusinessAnalysis struct { |
|
|
|
|
|
|
|
|
DataDate string `xorm:"NULL"` |
|
|
DataDate string `xorm:"NULL"` |
|
|
|
|
|
|
|
|
CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
UserLocation string `xorm:"NULL"` |
|
|
|
|
|
|
|
|
CloudBrainTaskNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuDebugJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuTrainJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
NpuInferenceJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
GpuBenchMarkJob int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CloudBrainRunTime int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
UserIndex float64 `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
UserIndexPrimitive float64 `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
|
|
|
|
|
|
UserLocation string `xorm:"NULL"` |
|
|
|
|
|
|
|
|
|
|
|
FocusOtherUser int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CollectDataset int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CollectedDataset int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
RecommendDataset int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CollectImage int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
CollectedImage int `xorm:"NOT NULL DEFAULT 0"` |
|
|
|
|
|
RecommendImage int `xorm:"NOT NULL DEFAULT 0"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type UserBusinessAnalysisQueryOptions struct { |
|
|
type UserBusinessAnalysisQueryOptions struct { |
|
@@ -410,8 +430,10 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
log.Info("truncate all data from table: " + tableName) |
|
|
log.Info("truncate all data from table: " + tableName) |
|
|
statictisSess.Exec("TRUNCATE TABLE " + tableName) |
|
|
statictisSess.Exec("TRUNCATE TABLE " + tableName) |
|
|
|
|
|
|
|
|
log.Info("pageStartTime:" + pageStartTime.Format("2006-01-02 15:04:05")) |
|
|
|
|
|
log.Info("pageEndTime time:" + pageEndTime.Format("2006-01-02 15:04:05")) |
|
|
|
|
|
|
|
|
StartTimeNextDay := pageStartTime.AddDate(0, 0, 1) |
|
|
|
|
|
EndTimeNextDay := pageEndTime.AddDate(0, 0, 1) |
|
|
|
|
|
log.Info("pageStartTime:" + pageStartTime.Format("2006-01-02 15:04:05") + " nextDay:" + StartTimeNextDay.Format("2006-01-02 15:04:05")) |
|
|
|
|
|
log.Info("pageEndTime time:" + pageEndTime.Format("2006-01-02 15:04:05") + " nextDay:" + EndTimeNextDay.Format("2006-01-02 15:04:05")) |
|
|
|
|
|
|
|
|
start_unix := pageStartTime.Unix() |
|
|
start_unix := pageStartTime.Unix() |
|
|
end_unix := pageEndTime.Unix() |
|
|
end_unix := pageEndTime.Unix() |
|
@@ -426,8 +448,8 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
CommentCountMap := queryComment(start_unix, end_unix) |
|
|
CommentCountMap := queryComment(start_unix, end_unix) |
|
|
FocusRepoCountMap := queryWatch(start_unix, end_unix) |
|
|
FocusRepoCountMap := queryWatch(start_unix, end_unix) |
|
|
StarRepoCountMap := queryStar(start_unix, end_unix) |
|
|
StarRepoCountMap := queryStar(start_unix, end_unix) |
|
|
WatchedCountMap := queryFollow(start_unix, end_unix) |
|
|
|
|
|
CommitCodeSizeMap := queryCommitCodeSize(start_unix, end_unix) |
|
|
|
|
|
|
|
|
WatchedCountMap, WatchOtherMap := queryFollow(start_unix, end_unix) |
|
|
|
|
|
CommitCodeSizeMap := queryCommitCodeSize(StartTimeNextDay.Unix(), EndTimeNextDay.Unix()) |
|
|
CommitDatasetSizeMap, CommitDatasetNumMap := queryDatasetSize(start_unix, end_unix) |
|
|
CommitDatasetSizeMap, CommitDatasetNumMap := queryDatasetSize(start_unix, end_unix) |
|
|
SolveIssueCountMap := querySolveIssue(start_unix, end_unix) |
|
|
SolveIssueCountMap := querySolveIssue(start_unix, end_unix) |
|
|
CreateRepoCountMap := queryUserCreateRepo(start_unix, end_unix) |
|
|
CreateRepoCountMap := queryUserCreateRepo(start_unix, end_unix) |
|
@@ -436,6 +458,12 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
OpenIIndexMap := queryUserRepoOpenIIndex(startTime.Unix(), end_unix) |
|
|
OpenIIndexMap := queryUserRepoOpenIIndex(startTime.Unix(), end_unix) |
|
|
CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) |
|
|
CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) |
|
|
AiModelManageMap := queryUserModel(start_unix, end_unix) |
|
|
AiModelManageMap := queryUserModel(start_unix, end_unix) |
|
|
|
|
|
|
|
|
|
|
|
CollectDataset, CollectedDataset := queryDatasetStars(start_unix, end_unix) |
|
|
|
|
|
RecommendDataset := queryRecommedDataSet(start_unix, end_unix) |
|
|
|
|
|
CollectImage, CollectedImage := queryImageStars(start_unix, end_unix) |
|
|
|
|
|
RecommendImage := queryRecommedImage(start_unix, end_unix) |
|
|
|
|
|
|
|
|
DataDate := currentTimeNow.Format("2006-01-02") + " 00:01" |
|
|
DataDate := currentTimeNow.Format("2006-01-02") + " 00:01" |
|
|
|
|
|
|
|
|
cond := "type != 1 and is_active=true" |
|
|
cond := "type != 1 and is_active=true" |
|
@@ -472,6 +500,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
dateRecordAll.IssueCount = getMapValue(dateRecordAll.ID, IssueCountMap) |
|
|
dateRecordAll.IssueCount = getMapValue(dateRecordAll.ID, IssueCountMap) |
|
|
dateRecordAll.CommentCount = getMapValue(dateRecordAll.ID, CommentCountMap) |
|
|
dateRecordAll.CommentCount = getMapValue(dateRecordAll.ID, CommentCountMap) |
|
|
dateRecordAll.FocusRepoCount = getMapValue(dateRecordAll.ID, FocusRepoCountMap) |
|
|
dateRecordAll.FocusRepoCount = getMapValue(dateRecordAll.ID, FocusRepoCountMap) |
|
|
|
|
|
dateRecordAll.FocusOtherUser = getMapValue(dateRecordAll.ID, WatchOtherMap) |
|
|
dateRecordAll.StarRepoCount = getMapValue(dateRecordAll.ID, StarRepoCountMap) |
|
|
dateRecordAll.StarRepoCount = getMapValue(dateRecordAll.ID, StarRepoCountMap) |
|
|
dateRecordAll.WatchedCount = getMapValue(dateRecordAll.ID, WatchedCountMap) |
|
|
dateRecordAll.WatchedCount = getMapValue(dateRecordAll.ID, WatchedCountMap) |
|
|
dateRecordAll.CommitCodeSize = getMapValue(dateRecordAll.ID, CommitCodeSizeMap) |
|
|
dateRecordAll.CommitCodeSize = getMapValue(dateRecordAll.ID, CommitCodeSizeMap) |
|
@@ -496,13 +525,20 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS |
|
|
dateRecordAll.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) |
|
|
dateRecordAll.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) |
|
|
dateRecordAll.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) |
|
|
dateRecordAll.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) |
|
|
dateRecordAll.CommitModelCount = getMapValue(dateRecordAll.ID, AiModelManageMap) |
|
|
dateRecordAll.CommitModelCount = getMapValue(dateRecordAll.ID, AiModelManageMap) |
|
|
dateRecordAll.UserIndex = getUserIndexFromAnalysisAll(dateRecordAll, ParaWeight) |
|
|
|
|
|
userIndexMap[dateRecordAll.ID] = dateRecordAll.UserIndex |
|
|
|
|
|
if maxUserIndex < dateRecordAll.UserIndex { |
|
|
|
|
|
maxUserIndex = dateRecordAll.UserIndex |
|
|
|
|
|
|
|
|
dateRecordAll.CollectDataset = getMapValue(dateRecordAll.ID, CollectDataset) |
|
|
|
|
|
dateRecordAll.CollectedDataset = getMapValue(dateRecordAll.ID, CollectedDataset) |
|
|
|
|
|
dateRecordAll.RecommendDataset = getMapValue(dateRecordAll.ID, RecommendDataset) |
|
|
|
|
|
dateRecordAll.CollectImage = getMapValue(dateRecordAll.ID, CollectImage) |
|
|
|
|
|
dateRecordAll.CollectedImage = getMapValue(dateRecordAll.ID, CollectedImage) |
|
|
|
|
|
dateRecordAll.RecommendImage = getMapValue(dateRecordAll.ID, RecommendImage) |
|
|
|
|
|
|
|
|
|
|
|
dateRecordAll.UserIndexPrimitive = getUserIndexFromAnalysisAll(dateRecordAll, ParaWeight) |
|
|
|
|
|
userIndexMap[dateRecordAll.ID] = dateRecordAll.UserIndexPrimitive |
|
|
|
|
|
if maxUserIndex < dateRecordAll.UserIndexPrimitive { |
|
|
|
|
|
maxUserIndex = dateRecordAll.UserIndexPrimitive |
|
|
} |
|
|
} |
|
|
if minUserIndex > dateRecordAll.UserIndex { |
|
|
|
|
|
minUserIndex = dateRecordAll.UserIndex |
|
|
|
|
|
|
|
|
if minUserIndex > dateRecordAll.UserIndexPrimitive { |
|
|
|
|
|
minUserIndex = dateRecordAll.UserIndexPrimitive |
|
|
} |
|
|
} |
|
|
dateRecordBatch = append(dateRecordBatch, dateRecordAll) |
|
|
dateRecordBatch = append(dateRecordBatch, dateRecordAll) |
|
|
if len(dateRecordBatch) >= BATCH_INSERT_SIZE { |
|
|
if len(dateRecordBatch) >= BATCH_INSERT_SIZE { |
|
@@ -552,7 +588,7 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static |
|
|
|
|
|
|
|
|
insertBatchSql := "INSERT INTO public." + tableName + |
|
|
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, " + |
|
|
"(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) " + |
|
|
|
|
|
|
|
|
"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) " + |
|
|
"VALUES" |
|
|
"VALUES" |
|
|
|
|
|
|
|
|
for i, record := range dateRecords { |
|
|
for i, record := range dateRecords { |
|
@@ -560,7 +596,8 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static |
|
|
", " + fmt.Sprint(record.IssueCount) + ", " + fmt.Sprint(record.CommentCount) + ", " + fmt.Sprint(record.FocusRepoCount) + ", " + fmt.Sprint(record.StarRepoCount) + |
|
|
", " + fmt.Sprint(record.IssueCount) + ", " + fmt.Sprint(record.CommentCount) + ", " + fmt.Sprint(record.FocusRepoCount) + ", " + fmt.Sprint(record.StarRepoCount) + |
|
|
", " + fmt.Sprint(record.WatchedCount) + ", " + fmt.Sprint(record.GiteaAgeMonth) + ", " + fmt.Sprint(record.CommitCodeSize) + ", " + fmt.Sprint(record.CommitDatasetSize) + |
|
|
", " + 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.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.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) + ")" |
|
|
if i < (len(dateRecords) - 1) { |
|
|
if i < (len(dateRecords) - 1) { |
|
|
insertBatchSql += "," |
|
|
insertBatchSql += "," |
|
|
} |
|
|
} |
|
@@ -628,7 +665,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
CommentCountMap := queryComment(start_unix, end_unix) |
|
|
CommentCountMap := queryComment(start_unix, end_unix) |
|
|
FocusRepoCountMap := queryWatch(start_unix, end_unix) |
|
|
FocusRepoCountMap := queryWatch(start_unix, end_unix) |
|
|
StarRepoCountMap := queryStar(start_unix, end_unix) |
|
|
StarRepoCountMap := queryStar(start_unix, end_unix) |
|
|
WatchedCountMap := queryFollow(start_unix, end_unix) |
|
|
|
|
|
|
|
|
WatchedCountMap, WatchOtherMap := queryFollow(start_unix, end_unix) |
|
|
|
|
|
|
|
|
CommitCodeSizeMap, err := GetAllUserKPIStats() |
|
|
CommitCodeSizeMap, err := GetAllUserKPIStats() |
|
|
if err != nil { |
|
|
if err != nil { |
|
@@ -643,6 +680,12 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
OpenIIndexMap := queryUserRepoOpenIIndex(start_unix, end_unix) |
|
|
OpenIIndexMap := queryUserRepoOpenIIndex(start_unix, end_unix) |
|
|
CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) |
|
|
CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(start_unix, end_unix) |
|
|
AiModelManageMap := queryUserModel(start_unix, end_unix) |
|
|
AiModelManageMap := queryUserModel(start_unix, end_unix) |
|
|
|
|
|
|
|
|
|
|
|
CollectDataset, CollectedDataset := queryDatasetStars(start_unix, end_unix) |
|
|
|
|
|
RecommendDataset := queryRecommedDataSet(start_unix, end_unix) |
|
|
|
|
|
CollectImage, CollectedImage := queryImageStars(start_unix, end_unix) |
|
|
|
|
|
RecommendImage := queryRecommedImage(start_unix, end_unix) |
|
|
|
|
|
|
|
|
statictisSess := xStatistic.NewSession() |
|
|
statictisSess := xStatistic.NewSession() |
|
|
defer statictisSess.Close() |
|
|
defer statictisSess.Close() |
|
|
|
|
|
|
|
@@ -683,13 +726,12 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
dateRecord.FocusRepoCount = getMapValue(dateRecord.ID, FocusRepoCountMap) |
|
|
dateRecord.FocusRepoCount = getMapValue(dateRecord.ID, FocusRepoCountMap) |
|
|
dateRecord.StarRepoCount = getMapValue(dateRecord.ID, StarRepoCountMap) |
|
|
dateRecord.StarRepoCount = getMapValue(dateRecord.ID, StarRepoCountMap) |
|
|
dateRecord.WatchedCount = getMapValue(dateRecord.ID, WatchedCountMap) |
|
|
dateRecord.WatchedCount = getMapValue(dateRecord.ID, WatchedCountMap) |
|
|
|
|
|
|
|
|
|
|
|
dateRecord.FocusOtherUser = getMapValue(dateRecord.ID, WatchOtherMap) |
|
|
if _, ok := CommitCodeSizeMap[dateRecord.Email]; !ok { |
|
|
if _, ok := CommitCodeSizeMap[dateRecord.Email]; !ok { |
|
|
dateRecord.CommitCodeSize = 0 |
|
|
dateRecord.CommitCodeSize = 0 |
|
|
} else { |
|
|
} else { |
|
|
dateRecord.CommitCodeSize = int(CommitCodeSizeMap[dateRecord.Email].CommitLines) |
|
|
dateRecord.CommitCodeSize = int(CommitCodeSizeMap[dateRecord.Email].CommitLines) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
dateRecord.CommitDatasetSize = getMapValue(dateRecord.ID, CommitDatasetSizeMap) |
|
|
dateRecord.CommitDatasetSize = getMapValue(dateRecord.ID, CommitDatasetSizeMap) |
|
|
dateRecord.CommitDatasetNum = getMapValue(dateRecord.ID, CommitDatasetNumMap) |
|
|
dateRecord.CommitDatasetNum = getMapValue(dateRecord.ID, CommitDatasetNumMap) |
|
|
dateRecord.SolveIssueCount = getMapValue(dateRecord.ID, SolveIssueCountMap) |
|
|
dateRecord.SolveIssueCount = getMapValue(dateRecord.ID, SolveIssueCountMap) |
|
@@ -715,7 +757,15 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, |
|
|
dateRecord.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) |
|
|
dateRecord.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) |
|
|
dateRecord.CloudBrainRunTime = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_CloudBrainRunTime", CloudBrainTaskItemMap) |
|
|
dateRecord.CloudBrainRunTime = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_CloudBrainRunTime", CloudBrainTaskItemMap) |
|
|
dateRecord.CommitModelCount = getMapValue(dateRecord.ID, AiModelManageMap) |
|
|
dateRecord.CommitModelCount = getMapValue(dateRecord.ID, AiModelManageMap) |
|
|
dateRecord.UserIndex = getUserIndex(dateRecord, ParaWeight) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dateRecord.CollectDataset = getMapValue(dateRecord.ID, CollectDataset) |
|
|
|
|
|
dateRecord.CollectedDataset = getMapValue(dateRecord.ID, CollectedDataset) |
|
|
|
|
|
dateRecord.RecommendDataset = getMapValue(dateRecord.ID, RecommendDataset) |
|
|
|
|
|
dateRecord.CollectImage = getMapValue(dateRecord.ID, CollectImage) |
|
|
|
|
|
dateRecord.CollectedImage = getMapValue(dateRecord.ID, CollectedImage) |
|
|
|
|
|
dateRecord.RecommendImage = getMapValue(dateRecord.ID, RecommendImage) |
|
|
|
|
|
|
|
|
|
|
|
dateRecord.UserIndexPrimitive = getUserIndex(dateRecord, ParaWeight) |
|
|
setUserMetrics(userMetrics, userRecord, start_unix, end_unix, dateRecord) |
|
|
setUserMetrics(userMetrics, userRecord, start_unix, end_unix, dateRecord) |
|
|
_, err = statictisSess.Insert(&dateRecord) |
|
|
_, err = statictisSess.Insert(&dateRecord) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@@ -765,7 +815,7 @@ func setUserMetrics(userMetrics map[string]int, user *User, start_time int64, en |
|
|
userMetrics["TotalActivateRegistUser"] = getMapKeyStringValue("TotalActivateRegistUser", userMetrics) + 1 |
|
|
userMetrics["TotalActivateRegistUser"] = getMapKeyStringValue("TotalActivateRegistUser", userMetrics) + 1 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if dateRecord.UserIndex > 0 || dateRecord.LoginCount > 0 { |
|
|
|
|
|
|
|
|
if getUserActivate(dateRecord) > 0 { |
|
|
userMetrics["HasActivityUser"] = getMapKeyStringValue("HasActivityUser", userMetrics) + 1 |
|
|
userMetrics["HasActivityUser"] = getMapKeyStringValue("HasActivityUser", userMetrics) + 1 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -802,7 +852,12 @@ func getUserIndexFromAnalysisAll(dateRecord UserBusinessAnalysisAll, ParaWeight |
|
|
result += float64(dateRecord.StarRepoCount) * getParaWeightValue("StarRepoCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.StarRepoCount) * getParaWeightValue("StarRepoCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.LoginCount) * getParaWeightValue("LoginCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.LoginCount) * getParaWeightValue("LoginCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.WatchedCount) * getParaWeightValue("WatchedCount", ParaWeight, 0.3) |
|
|
result += float64(dateRecord.WatchedCount) * getParaWeightValue("WatchedCount", ParaWeight, 0.3) |
|
|
result += float64(dateRecord.CommitCodeSize) * getParaWeightValue("CommitCodeSize", ParaWeight, 0.1) |
|
|
|
|
|
|
|
|
codeLine := float64(dateRecord.CommitCodeSize) |
|
|
|
|
|
limitCodeLine := getParaWeightValue("LimitCommitCodeSize", ParaWeight, 1000) |
|
|
|
|
|
if codeLine >= limitCodeLine { |
|
|
|
|
|
codeLine = limitCodeLine |
|
|
|
|
|
} |
|
|
|
|
|
result += codeLine * getParaWeightValue("CommitCodeSize", ParaWeight, 0.01) |
|
|
result += float64(dateRecord.SolveIssueCount) * getParaWeightValue("SolveIssueCount", ParaWeight, 0.2) |
|
|
result += float64(dateRecord.SolveIssueCount) * getParaWeightValue("SolveIssueCount", ParaWeight, 0.2) |
|
|
result += float64(dateRecord.EncyclopediasCount) * getParaWeightValue("EncyclopediasCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.EncyclopediasCount) * getParaWeightValue("EncyclopediasCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.CreateRepoCount) * getParaWeightValue("CreateRepoCount", ParaWeight, 0.05) |
|
|
result += float64(dateRecord.CreateRepoCount) * getParaWeightValue("CreateRepoCount", ParaWeight, 0.05) |
|
@@ -810,6 +865,34 @@ func getUserIndexFromAnalysisAll(dateRecord UserBusinessAnalysisAll, ParaWeight |
|
|
result += float64(dateRecord.CommitModelCount) * getParaWeightValue("CommitModelCount", ParaWeight, 0.2) |
|
|
result += float64(dateRecord.CommitModelCount) * getParaWeightValue("CommitModelCount", ParaWeight, 0.2) |
|
|
result += dateRecord.OpenIIndex * getParaWeightValue("OpenIIndex", ParaWeight, 0.1) |
|
|
result += dateRecord.OpenIIndex * getParaWeightValue("OpenIIndex", ParaWeight, 0.1) |
|
|
|
|
|
|
|
|
|
|
|
result += float64(dateRecord.CollectDataset) * getParaWeightValue("CollectDataset", ParaWeight, 0.1) |
|
|
|
|
|
result += float64(dateRecord.CollectedDataset) * getParaWeightValue("CollectedDataset", ParaWeight, 0.1) |
|
|
|
|
|
result += float64(dateRecord.RecommendDataset) * getParaWeightValue("RecommendDataset", ParaWeight, 0.2) |
|
|
|
|
|
result += float64(dateRecord.CollectImage) * getParaWeightValue("CollectImage", ParaWeight, 0.1) |
|
|
|
|
|
result += float64(dateRecord.CollectedImage) * getParaWeightValue("CollectedImage", ParaWeight, 0.1) |
|
|
|
|
|
result += float64(dateRecord.RecommendImage) * getParaWeightValue("RecommendImage", ParaWeight, 0.2) |
|
|
|
|
|
|
|
|
|
|
|
return result |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func getUserActivate(dateRecord UserBusinessAnalysis) int { |
|
|
|
|
|
var result int |
|
|
|
|
|
result += dateRecord.CodeMergeCount |
|
|
|
|
|
result += dateRecord.CommitCount |
|
|
|
|
|
result += dateRecord.IssueCount |
|
|
|
|
|
result += dateRecord.CommentCount |
|
|
|
|
|
result += dateRecord.FocusRepoCount |
|
|
|
|
|
result += dateRecord.StarRepoCount |
|
|
|
|
|
result += dateRecord.SolveIssueCount |
|
|
|
|
|
result += dateRecord.EncyclopediasCount |
|
|
|
|
|
result += dateRecord.CreateRepoCount |
|
|
|
|
|
result += dateRecord.CloudBrainTaskNum |
|
|
|
|
|
result += dateRecord.CommitModelCount |
|
|
|
|
|
result += dateRecord.CommitDatasetNum |
|
|
|
|
|
result += dateRecord.FocusOtherUser |
|
|
|
|
|
result += dateRecord.CollectDataset |
|
|
|
|
|
result += dateRecord.CollectImage |
|
|
|
|
|
result += dateRecord.CommitCodeSize |
|
|
return result |
|
|
return result |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -831,12 +914,12 @@ func getUserIndex(dateRecord UserBusinessAnalysis, ParaWeight map[string]float64 |
|
|
result += float64(dateRecord.StarRepoCount) * getParaWeightValue("StarRepoCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.StarRepoCount) * getParaWeightValue("StarRepoCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.LoginCount) * getParaWeightValue("LoginCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.LoginCount) * getParaWeightValue("LoginCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.WatchedCount) * getParaWeightValue("WatchedCount", ParaWeight, 0.3) |
|
|
result += float64(dateRecord.WatchedCount) * getParaWeightValue("WatchedCount", ParaWeight, 0.3) |
|
|
codeLine := float64(dateRecord.CommitCodeSize) / 1000 |
|
|
|
|
|
limitCodeLine := getParaWeightValue("LimitCommitCodeSize", ParaWeight, 100) |
|
|
|
|
|
|
|
|
codeLine := float64(dateRecord.CommitCodeSize) |
|
|
|
|
|
limitCodeLine := getParaWeightValue("LimitCommitCodeSize", ParaWeight, 1000) |
|
|
if codeLine >= limitCodeLine { |
|
|
if codeLine >= limitCodeLine { |
|
|
codeLine = limitCodeLine |
|
|
codeLine = limitCodeLine |
|
|
} |
|
|
} |
|
|
result += codeLine * getParaWeightValue("CommitCodeSize", ParaWeight, 0.1) |
|
|
|
|
|
|
|
|
result += codeLine * getParaWeightValue("CommitCodeSize", ParaWeight, 0.01) |
|
|
result += float64(dateRecord.SolveIssueCount) * getParaWeightValue("SolveIssueCount", ParaWeight, 0.2) |
|
|
result += float64(dateRecord.SolveIssueCount) * getParaWeightValue("SolveIssueCount", ParaWeight, 0.2) |
|
|
result += float64(dateRecord.EncyclopediasCount) * getParaWeightValue("EncyclopediasCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.EncyclopediasCount) * getParaWeightValue("EncyclopediasCount", ParaWeight, 0.1) |
|
|
result += float64(dateRecord.CreateRepoCount) * getParaWeightValue("CreateRepoCount", ParaWeight, 0.05) |
|
|
result += float64(dateRecord.CreateRepoCount) * getParaWeightValue("CreateRepoCount", ParaWeight, 0.05) |
|
@@ -844,6 +927,13 @@ func getUserIndex(dateRecord UserBusinessAnalysis, ParaWeight map[string]float64 |
|
|
result += float64(dateRecord.CommitModelCount) * getParaWeightValue("CommitModelCount", ParaWeight, 0.2) |
|
|
result += float64(dateRecord.CommitModelCount) * getParaWeightValue("CommitModelCount", ParaWeight, 0.2) |
|
|
result += dateRecord.OpenIIndex * getParaWeightValue("OpenIIndex", ParaWeight, 0.1) |
|
|
result += dateRecord.OpenIIndex * getParaWeightValue("OpenIIndex", ParaWeight, 0.1) |
|
|
|
|
|
|
|
|
|
|
|
result += float64(dateRecord.CollectDataset) * getParaWeightValue("CollectDataset", ParaWeight, 0.1) |
|
|
|
|
|
result += float64(dateRecord.CollectedDataset) * getParaWeightValue("CollectedDataset", ParaWeight, 0.1) |
|
|
|
|
|
result += float64(dateRecord.RecommendDataset) * getParaWeightValue("RecommendDataset", ParaWeight, 0.2) |
|
|
|
|
|
result += float64(dateRecord.CollectImage) * getParaWeightValue("CollectImage", ParaWeight, 0.1) |
|
|
|
|
|
result += float64(dateRecord.CollectedImage) * getParaWeightValue("CollectedImage", ParaWeight, 0.1) |
|
|
|
|
|
result += float64(dateRecord.RecommendImage) * getParaWeightValue("RecommendImage", ParaWeight, 0.2) |
|
|
|
|
|
|
|
|
return result |
|
|
return result |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -1134,17 +1224,18 @@ func queryStar(start_unix int64, end_unix int64) map[int64]int { |
|
|
return resultMap |
|
|
return resultMap |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func queryFollow(start_unix int64, end_unix int64) map[int64]int { |
|
|
|
|
|
|
|
|
func queryFollow(start_unix int64, end_unix int64) (map[int64]int, 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) |
|
|
|
|
|
resultFocusedByOtherMap := make(map[int64]int) |
|
|
cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) |
|
|
cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) |
|
|
|
|
|
|
|
|
count, err := sess.Where(cond).Count(new(Follow)) |
|
|
count, err := sess.Where(cond).Count(new(Follow)) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Info("query follow error. return.") |
|
|
log.Info("query follow error. return.") |
|
|
return resultMap |
|
|
|
|
|
|
|
|
return resultMap, resultFocusedByOtherMap |
|
|
} |
|
|
} |
|
|
var indexTotal int64 |
|
|
var indexTotal int64 |
|
|
indexTotal = 0 |
|
|
indexTotal = 0 |
|
@@ -1160,6 +1251,11 @@ func queryFollow(start_unix int64, end_unix int64) map[int64]int { |
|
|
} else { |
|
|
} else { |
|
|
resultMap[followRecord.FollowID] += 1 |
|
|
resultMap[followRecord.FollowID] += 1 |
|
|
} |
|
|
} |
|
|
|
|
|
if _, ok := resultFocusedByOtherMap[followRecord.UserID]; !ok { |
|
|
|
|
|
resultFocusedByOtherMap[followRecord.UserID] = 1 |
|
|
|
|
|
} else { |
|
|
|
|
|
resultFocusedByOtherMap[followRecord.UserID] += 1 |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
indexTotal += PAGE_SIZE |
|
|
indexTotal += PAGE_SIZE |
|
@@ -1168,7 +1264,215 @@ func queryFollow(start_unix int64, end_unix int64) map[int64]int { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return resultMap |
|
|
|
|
|
|
|
|
return resultMap, resultFocusedByOtherMap |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func queryRecommedDataSet(start_unix int64, end_unix int64) map[int64]int { |
|
|
|
|
|
sess := x.NewSession() |
|
|
|
|
|
defer sess.Close() |
|
|
|
|
|
userIdDdatasetMap := make(map[int64]int) |
|
|
|
|
|
cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) + " and recommend=true" |
|
|
|
|
|
count, err := sess.Where(cond).Count(new(Dataset)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Info("query recommend dataset error. return.") |
|
|
|
|
|
return userIdDdatasetMap |
|
|
|
|
|
} |
|
|
|
|
|
var indexTotal int64 |
|
|
|
|
|
indexTotal = 0 |
|
|
|
|
|
for { |
|
|
|
|
|
sess.Select("id,user_id,recommend").Where(cond).Table(new(Dataset)).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) |
|
|
|
|
|
datasetList := make([]*Dataset, 0) |
|
|
|
|
|
sess.Find(&datasetList) |
|
|
|
|
|
log.Info("query datasetList size=" + fmt.Sprint(len(datasetList))) |
|
|
|
|
|
for _, datasetRecord := range datasetList { |
|
|
|
|
|
if _, ok := userIdDdatasetMap[datasetRecord.UserID]; !ok { |
|
|
|
|
|
userIdDdatasetMap[datasetRecord.UserID] = 1 |
|
|
|
|
|
} else { |
|
|
|
|
|
userIdDdatasetMap[datasetRecord.UserID] += 1 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
indexTotal += PAGE_SIZE |
|
|
|
|
|
if indexTotal >= count { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return userIdDdatasetMap |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func queryAllDataSet() (map[int64]int64, map[int64]int64) { |
|
|
|
|
|
sess := x.NewSession() |
|
|
|
|
|
defer sess.Close() |
|
|
|
|
|
datasetUserIdMap := make(map[int64]int64) |
|
|
|
|
|
userIdDdatasetMap := make(map[int64]int64) |
|
|
|
|
|
count, err := sess.Count(new(Dataset)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Info("query dataset error. return.") |
|
|
|
|
|
return datasetUserIdMap, userIdDdatasetMap |
|
|
|
|
|
} |
|
|
|
|
|
var indexTotal int64 |
|
|
|
|
|
indexTotal = 0 |
|
|
|
|
|
for { |
|
|
|
|
|
sess.Select("id,user_id").Table(new(Dataset)).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) |
|
|
|
|
|
datasetList := make([]*Dataset, 0) |
|
|
|
|
|
sess.Find(&datasetList) |
|
|
|
|
|
log.Info("query datasetList size=" + fmt.Sprint(len(datasetList))) |
|
|
|
|
|
for _, datasetRecord := range datasetList { |
|
|
|
|
|
datasetUserIdMap[datasetRecord.ID] = datasetRecord.UserID |
|
|
|
|
|
if _, ok := userIdDdatasetMap[datasetRecord.UserID]; !ok { |
|
|
|
|
|
userIdDdatasetMap[datasetRecord.UserID] = 1 |
|
|
|
|
|
} else { |
|
|
|
|
|
userIdDdatasetMap[datasetRecord.UserID] += 1 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
indexTotal += PAGE_SIZE |
|
|
|
|
|
if indexTotal >= count { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return datasetUserIdMap, userIdDdatasetMap |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func queryRecommedImage(start_unix int64, end_unix int64) map[int64]int { |
|
|
|
|
|
sess := x.NewSession() |
|
|
|
|
|
defer sess.Close() |
|
|
|
|
|
userIdImageMap := make(map[int64]int) |
|
|
|
|
|
cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) + " and type=5" |
|
|
|
|
|
count, err := sess.Where(cond).Count(new(Image)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Info("query recommend image error. return.") |
|
|
|
|
|
return userIdImageMap |
|
|
|
|
|
} |
|
|
|
|
|
var indexTotal int64 |
|
|
|
|
|
indexTotal = 0 |
|
|
|
|
|
for { |
|
|
|
|
|
sess.Select("id,uid,type").Where(cond).Table(new(Image)).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) |
|
|
|
|
|
imageList := make([]*Image, 0) |
|
|
|
|
|
sess.Find(&imageList) |
|
|
|
|
|
log.Info("query imageList size=" + fmt.Sprint(len(imageList))) |
|
|
|
|
|
for _, imageRecord := range imageList { |
|
|
|
|
|
if _, ok := userIdImageMap[imageRecord.UID]; !ok { |
|
|
|
|
|
userIdImageMap[imageRecord.UID] = 1 |
|
|
|
|
|
} else { |
|
|
|
|
|
userIdImageMap[imageRecord.UID] += 1 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
indexTotal += PAGE_SIZE |
|
|
|
|
|
if indexTotal >= count { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return userIdImageMap |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func queryAllImage() (map[int64]int64, map[int64]int64) { |
|
|
|
|
|
sess := x.NewSession() |
|
|
|
|
|
defer sess.Close() |
|
|
|
|
|
imageUserIdMap := make(map[int64]int64) |
|
|
|
|
|
userIdDImageMap := make(map[int64]int64) |
|
|
|
|
|
count, err := sess.Count(new(Image)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Info("query image error. return.") |
|
|
|
|
|
return imageUserIdMap, userIdDImageMap |
|
|
|
|
|
} |
|
|
|
|
|
var indexTotal int64 |
|
|
|
|
|
indexTotal = 0 |
|
|
|
|
|
for { |
|
|
|
|
|
sess.Select("id,uid").Table(new(Image)).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) |
|
|
|
|
|
imageList := make([]*Image, 0) |
|
|
|
|
|
sess.Find(&imageList) |
|
|
|
|
|
log.Info("query imageList size=" + fmt.Sprint(len(imageList))) |
|
|
|
|
|
for _, imageRecord := range imageList { |
|
|
|
|
|
imageUserIdMap[imageRecord.ID] = imageRecord.UID |
|
|
|
|
|
if _, ok := userIdDImageMap[imageRecord.UID]; !ok { |
|
|
|
|
|
userIdDImageMap[imageRecord.UID] = 1 |
|
|
|
|
|
} else { |
|
|
|
|
|
userIdDImageMap[imageRecord.UID] += 1 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
indexTotal += PAGE_SIZE |
|
|
|
|
|
if indexTotal >= count { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return imageUserIdMap, userIdDImageMap |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func queryDatasetStars(start_unix int64, end_unix int64) (map[int64]int, map[int64]int) { |
|
|
|
|
|
sess := x.NewSession() |
|
|
|
|
|
defer sess.Close() |
|
|
|
|
|
datasetCollect := make(map[int64]int) |
|
|
|
|
|
datasetCollected := make(map[int64]int) |
|
|
|
|
|
datasetUserIdMap, _ := queryAllDataSet() |
|
|
|
|
|
cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) |
|
|
|
|
|
count, err := sess.Where(cond).Count(new(DatasetStar)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Info("query follow error. return.") |
|
|
|
|
|
return datasetCollect, datasetCollected |
|
|
|
|
|
} |
|
|
|
|
|
var indexTotal int64 |
|
|
|
|
|
indexTotal = 0 |
|
|
|
|
|
for { |
|
|
|
|
|
sess.Select("id,uid,dataset_id").Table(new(DatasetStar)).Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) |
|
|
|
|
|
datasetStarList := make([]*DatasetStar, 0) |
|
|
|
|
|
sess.Find(&datasetStarList) |
|
|
|
|
|
log.Info("query datasetStarList size=" + fmt.Sprint(len(datasetStarList))) |
|
|
|
|
|
for _, datasetStarRecord := range datasetStarList { |
|
|
|
|
|
if _, ok := datasetCollect[datasetStarRecord.UID]; !ok { |
|
|
|
|
|
datasetCollect[datasetStarRecord.UID] = 1 |
|
|
|
|
|
} else { |
|
|
|
|
|
datasetCollect[datasetStarRecord.UID] += 1 |
|
|
|
|
|
} |
|
|
|
|
|
if _, ok := datasetCollected[datasetUserIdMap[datasetStarRecord.DatasetID]]; !ok { |
|
|
|
|
|
datasetCollected[datasetUserIdMap[datasetStarRecord.DatasetID]] = 1 |
|
|
|
|
|
} else { |
|
|
|
|
|
datasetCollected[datasetUserIdMap[datasetStarRecord.DatasetID]] += 1 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
indexTotal += PAGE_SIZE |
|
|
|
|
|
if indexTotal >= count { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return datasetCollect, datasetCollected |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func queryImageStars(start_unix int64, end_unix int64) (map[int64]int, map[int64]int) { |
|
|
|
|
|
sess := x.NewSession() |
|
|
|
|
|
defer sess.Close() |
|
|
|
|
|
imageCollect := make(map[int64]int) |
|
|
|
|
|
imageCollected := make(map[int64]int) |
|
|
|
|
|
imageUserIdMap, _ := queryAllDataSet() |
|
|
|
|
|
cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) |
|
|
|
|
|
count, err := sess.Where(cond).Count(new(ImageStar)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Info("query follow error. return.") |
|
|
|
|
|
return imageCollect, imageCollected |
|
|
|
|
|
} |
|
|
|
|
|
var indexTotal int64 |
|
|
|
|
|
indexTotal = 0 |
|
|
|
|
|
for { |
|
|
|
|
|
sess.Select("id,uid,dataset_id").Table(new(ImageStar)).Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) |
|
|
|
|
|
imageStarList := make([]*ImageStar, 0) |
|
|
|
|
|
sess.Find(&imageStarList) |
|
|
|
|
|
log.Info("query imageStarList size=" + fmt.Sprint(len(imageStarList))) |
|
|
|
|
|
for _, imageStarRecord := range imageStarList { |
|
|
|
|
|
if _, ok := imageCollect[imageStarRecord.UID]; !ok { |
|
|
|
|
|
imageCollect[imageStarRecord.UID] = 1 |
|
|
|
|
|
} else { |
|
|
|
|
|
imageCollect[imageStarRecord.UID] += 1 |
|
|
|
|
|
} |
|
|
|
|
|
if _, ok := imageCollected[imageUserIdMap[imageStarRecord.ImageID]]; !ok { |
|
|
|
|
|
imageCollected[imageUserIdMap[imageStarRecord.ImageID]] = 1 |
|
|
|
|
|
} else { |
|
|
|
|
|
imageCollected[imageUserIdMap[imageStarRecord.ImageID]] += 1 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
indexTotal += PAGE_SIZE |
|
|
|
|
|
if indexTotal >= count { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return imageCollect, imageCollected |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func queryDatasetSize(start_unix int64, end_unix int64) (map[int64]int, map[int64]int) { |
|
|
func queryDatasetSize(start_unix int64, end_unix int64) (map[int64]int, map[int64]int) { |
|
|