From 6a0ea6e545953459ce94686ae8009dac7109fd7c Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 20 Apr 2022 15:26:31 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 49 ++++++++++++++++++++++++-------- models/user_business_struct.go | 48 +++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 12 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 34d84555cb..31e8cf6ac9 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -93,6 +93,14 @@ type UserBusinessAnalysisAll struct { CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` UserIndex 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 { @@ -170,6 +178,14 @@ type UserBusinessAnalysis struct { CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` UserIndex 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 { @@ -410,8 +426,10 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS log.Info("truncate all data from 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() end_unix := pageEndTime.Unix() @@ -426,8 +444,8 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS CommentCountMap := queryComment(start_unix, end_unix) FocusRepoCountMap := queryWatch(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) SolveIssueCountMap := querySolveIssue(start_unix, end_unix) CreateRepoCountMap := queryUserCreateRepo(start_unix, end_unix) @@ -472,6 +490,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS dateRecordAll.IssueCount = getMapValue(dateRecordAll.ID, IssueCountMap) dateRecordAll.CommentCount = getMapValue(dateRecordAll.ID, CommentCountMap) dateRecordAll.FocusRepoCount = getMapValue(dateRecordAll.ID, FocusRepoCountMap) + dateRecordAll.FocusOtherUser = getMapValue(dateRecordAll.ID, WatchOtherMap) dateRecordAll.StarRepoCount = getMapValue(dateRecordAll.ID, StarRepoCountMap) dateRecordAll.WatchedCount = getMapValue(dateRecordAll.ID, WatchedCountMap) dateRecordAll.CommitCodeSize = getMapValue(dateRecordAll.ID, CommitCodeSizeMap) @@ -552,7 +571,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) " + + "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) " + "VALUES" for i, record := range dateRecords { @@ -560,7 +579,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.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.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) if i < (len(dateRecords) - 1) { insertBatchSql += "," } @@ -628,7 +648,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, CommentCountMap := queryComment(start_unix, end_unix) FocusRepoCountMap := queryWatch(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() if err != nil { @@ -683,13 +703,12 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.FocusRepoCount = getMapValue(dateRecord.ID, FocusRepoCountMap) dateRecord.StarRepoCount = getMapValue(dateRecord.ID, StarRepoCountMap) dateRecord.WatchedCount = getMapValue(dateRecord.ID, WatchedCountMap) - + dateRecord.FocusOtherUser = getMapValue(dateRecord.ID, WatchOtherMap) if _, ok := CommitCodeSizeMap[dateRecord.Email]; !ok { dateRecord.CommitCodeSize = 0 } else { dateRecord.CommitCodeSize = int(CommitCodeSizeMap[dateRecord.Email].CommitLines) } - dateRecord.CommitDatasetSize = getMapValue(dateRecord.ID, CommitDatasetSizeMap) dateRecord.CommitDatasetNum = getMapValue(dateRecord.ID, CommitDatasetNumMap) dateRecord.SolveIssueCount = getMapValue(dateRecord.ID, SolveIssueCountMap) @@ -1134,17 +1153,18 @@ func queryStar(start_unix int64, end_unix int64) map[int64]int { 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() defer sess.Close() resultMap := make(map[int64]int) + resultFocusedByOtherMap := make(map[int64]int) cond := " created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix) count, err := sess.Where(cond).Count(new(Follow)) if err != nil { log.Info("query follow error. return.") - return resultMap + return resultMap, resultFocusedByOtherMap } var indexTotal int64 indexTotal = 0 @@ -1160,6 +1180,11 @@ func queryFollow(start_unix int64, end_unix int64) map[int64]int { } else { resultMap[followRecord.FollowID] += 1 } + if _, ok := resultFocusedByOtherMap[followRecord.UserID]; !ok { + resultFocusedByOtherMap[followRecord.UserID] = 1 + } else { + resultFocusedByOtherMap[followRecord.UserID] += 1 + } } indexTotal += PAGE_SIZE @@ -1168,7 +1193,7 @@ func queryFollow(start_unix int64, end_unix int64) map[int64]int { } } - return resultMap + return resultMap, resultFocusedByOtherMap } func queryDatasetSize(start_unix int64, end_unix int64) (map[int64]int, map[int64]int) { diff --git a/models/user_business_struct.go b/models/user_business_struct.go index 17d9f046f6..bcf2f06c0e 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -56,6 +56,14 @@ type UserBusinessAnalysisCurrentYear struct { CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` UserIndex 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 UserBusinessAnalysisLast30Day struct { @@ -112,6 +120,14 @@ type UserBusinessAnalysisLast30Day struct { CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` UserIndex 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 UserBusinessAnalysisLastMonth struct { @@ -168,6 +184,14 @@ type UserBusinessAnalysisLastMonth struct { CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` UserIndex 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 UserBusinessAnalysisCurrentMonth struct { @@ -224,6 +248,14 @@ type UserBusinessAnalysisCurrentMonth struct { CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` UserIndex 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 UserBusinessAnalysisCurrentWeek struct { @@ -280,6 +312,14 @@ type UserBusinessAnalysisCurrentWeek struct { CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` UserIndex 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 UserBusinessAnalysisYesterday struct { @@ -336,6 +376,14 @@ type UserBusinessAnalysisYesterday struct { CommitDatasetNum int `xorm:"NOT NULL DEFAULT 0"` UserIndex 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 UserAnalysisPara struct { -- 2.34.1 From 843555ad9339d26977cf9af6031a5b963a3eb27b Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Apr 2022 10:31:50 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 235 +++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 31e8cf6ac9..65c54bb427 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -454,6 +454,12 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS OpenIIndexMap := queryUserRepoOpenIIndex(startTime.Unix(), end_unix) CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(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" cond := "type != 1 and is_active=true" @@ -515,6 +521,13 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS dateRecordAll.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) dateRecordAll.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) dateRecordAll.CommitModelCount = getMapValue(dateRecordAll.ID, AiModelManageMap) + 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.UserIndex = getUserIndexFromAnalysisAll(dateRecordAll, ParaWeight) userIndexMap[dateRecordAll.ID] = dateRecordAll.UserIndex if maxUserIndex < dateRecordAll.UserIndex { @@ -663,6 +676,12 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, OpenIIndexMap := queryUserRepoOpenIIndex(start_unix, end_unix) CloudBrainTaskMap, CloudBrainTaskItemMap := queryCloudBrainTask(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() defer statictisSess.Close() @@ -734,6 +753,14 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) dateRecord.CloudBrainRunTime = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_CloudBrainRunTime", CloudBrainTaskItemMap) dateRecord.CommitModelCount = getMapValue(dateRecord.ID, AiModelManageMap) + + 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.UserIndex = getUserIndex(dateRecord, ParaWeight) setUserMetrics(userMetrics, userRecord, start_unix, end_unix, dateRecord) _, err = statictisSess.Insert(&dateRecord) @@ -1196,6 +1223,214 @@ func queryFollow(start_unix int64, end_unix int64) (map[int64]int, map[int64]int 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) { sess := x.NewSession() defer sess.Close() -- 2.34.1 From 7126ec255758931b16825d97acb33a32015de28e Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Apr 2022 10:49:23 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 65c54bb427..1bd597bf50 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -592,8 +592,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.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.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) + ")" if i < (len(dateRecords) - 1) { insertBatchSql += "," } -- 2.34.1 From eaaa456e5f940370e8fcf7c09476e1a65889e785 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Apr 2022 16:01:31 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82=E8=A7=A3=E5=86=B3Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 66 ++++++++------- models/user_business_struct.go | 140 ++++++++++++++++--------------- public/home/search.js | 20 ++--- 3 files changed, 118 insertions(+), 108 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 1bd597bf50..316fec78b0 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -82,17 +82,19 @@ type UserBusinessAnalysisAll struct { DataDate string `xorm:"NULL"` //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"` @@ -167,17 +169,19 @@ type UserBusinessAnalysis struct { 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"` @@ -528,13 +532,13 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS dateRecordAll.CollectedImage = getMapValue(dateRecordAll.ID, CollectedImage) dateRecordAll.RecommendImage = getMapValue(dateRecordAll.ID, RecommendImage) - dateRecordAll.UserIndex = getUserIndexFromAnalysisAll(dateRecordAll, ParaWeight) - userIndexMap[dateRecordAll.ID] = dateRecordAll.UserIndex - if maxUserIndex < dateRecordAll.UserIndex { - maxUserIndex = dateRecordAll.UserIndex + 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) if len(dateRecordBatch) >= BATCH_INSERT_SIZE { @@ -584,7 +588,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) " + + "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" for i, record := range dateRecords { @@ -593,7 +597,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.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) { insertBatchSql += "," } @@ -761,7 +765,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.CollectedImage = getMapValue(dateRecord.ID, CollectedImage) dateRecord.RecommendImage = getMapValue(dateRecord.ID, RecommendImage) - dateRecord.UserIndex = getUserIndex(dateRecord, ParaWeight) + dateRecord.UserIndexPrimitive = getUserIndex(dateRecord, ParaWeight) setUserMetrics(userMetrics, userRecord, start_unix, end_unix, dateRecord) _, err = statictisSess.Insert(&dateRecord) if err != nil { diff --git a/models/user_business_struct.go b/models/user_business_struct.go index bcf2f06c0e..86aecd5453 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -45,17 +45,18 @@ type UserBusinessAnalysisCurrentYear struct { Name string `xorm:"NOT 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"` @@ -109,17 +110,18 @@ type UserBusinessAnalysisLast30Day struct { Name string `xorm:"NOT 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"` @@ -173,17 +175,18 @@ type UserBusinessAnalysisLastMonth struct { Name string `xorm:"NOT 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"` @@ -237,17 +240,18 @@ type UserBusinessAnalysisCurrentMonth struct { Name string `xorm:"NOT 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"` @@ -301,17 +305,19 @@ type UserBusinessAnalysisCurrentWeek struct { Name string `xorm:"NOT 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"` @@ -365,17 +371,19 @@ type UserBusinessAnalysisYesterday struct { Name string `xorm:"NOT 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"` diff --git a/public/home/search.js b/public/home/search.js index c55d1807c8..2fac953588 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -810,14 +810,7 @@ var repoAndOrgEN={ function page(current){ currentPage=current; - startIndex = currentPage -1; - if(startIndex < 1){ - startIndex = 1; - } - endIndex = currentPage + 2; - if(endIndex >= totalPage){ - endIndex = totalPage; - } + doSearch(currentSearchTableName,currentSearchKeyword,current,pageSize,false,currentSearchSortBy,OnlySearchLabel); } @@ -888,9 +881,14 @@ function getYPosition(e){ var html =""; console.log("currentPage=" + currentPage); console.log("privateTotal=" + privateTotal); - // if(totalPage==0){ - // return; - // } + startIndex = currentPage -1; + if(startIndex < 1){ + startIndex = 1; + } + endIndex = currentPage + 2; + if(endIndex >= totalPage){ + endIndex = totalPage; + } html += "" + getLabel(isZh,"search_input_total") + " " + totalNum + " " + getLabel(isZh,"search_srtip") + "" if(currentPage > 1){ html += "" + getLabel(isZh,"search_home_page") + ""; -- 2.34.1 From 395c4a9bf9302a4dd0cbff52beddf1058e8ff256 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Apr 2022 16:08:30 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82=E8=A7=A3=E5=86=B3Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 316fec78b0..48b9205c69 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -852,7 +852,12 @@ func getUserIndexFromAnalysisAll(dateRecord UserBusinessAnalysisAll, ParaWeight result += float64(dateRecord.StarRepoCount) * getParaWeightValue("StarRepoCount", ParaWeight, 0.1) result += float64(dateRecord.LoginCount) * getParaWeightValue("LoginCount", ParaWeight, 0.1) 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.EncyclopediasCount) * getParaWeightValue("EncyclopediasCount", ParaWeight, 0.1) result += float64(dateRecord.CreateRepoCount) * getParaWeightValue("CreateRepoCount", ParaWeight, 0.05) @@ -881,12 +886,12 @@ func getUserIndex(dateRecord UserBusinessAnalysis, ParaWeight map[string]float64 result += float64(dateRecord.StarRepoCount) * getParaWeightValue("StarRepoCount", ParaWeight, 0.1) result += float64(dateRecord.LoginCount) * getParaWeightValue("LoginCount", ParaWeight, 0.1) 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 { 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.EncyclopediasCount) * getParaWeightValue("EncyclopediasCount", ParaWeight, 0.1) result += float64(dateRecord.CreateRepoCount) * getParaWeightValue("CreateRepoCount", ParaWeight, 0.05) -- 2.34.1 From 02226743123ee84a5c2dde730540c7b1ea93df43 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 22 Apr 2022 10:25:39 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=85=B3=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 37 +++- options/locale/locale_en-US.ini | 10 +- options/locale/locale_zh-CN.ini | 10 +- routers/repo/user_data_analysis.go | 273 ++++++++++++++++--------- web_src/js/components/UserAnalysis.vue | 55 ++++- 5 files changed, 281 insertions(+), 104 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 48b9205c69..2d7592baf2 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -815,7 +815,7 @@ func setUserMetrics(userMetrics map[string]int, user *User, start_time int64, en userMetrics["TotalActivateRegistUser"] = getMapKeyStringValue("TotalActivateRegistUser", userMetrics) + 1 } - if dateRecord.UserIndex > 0 || dateRecord.LoginCount > 0 { + if getUserActivate(dateRecord) > 0 { userMetrics["HasActivityUser"] = getMapKeyStringValue("HasActivityUser", userMetrics) + 1 } @@ -865,6 +865,34 @@ func getUserIndexFromAnalysisAll(dateRecord UserBusinessAnalysisAll, ParaWeight result += float64(dateRecord.CommitModelCount) * getParaWeightValue("CommitModelCount", ParaWeight, 0.2) 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 } @@ -899,6 +927,13 @@ func getUserIndex(dateRecord UserBusinessAnalysis, ParaWeight map[string]float64 result += float64(dateRecord.CommitModelCount) * getParaWeightValue("CommitModelCount", ParaWeight, 0.2) 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 } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index f53bea7b1e..c96e6af3fc 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -507,8 +507,16 @@ static.CloudBrainTaskNum=CloudBrain Task Count static.CloudBrainRunTime=CloudBrain Run Time static.CommitDatasetNum=Commit Dataset Count static.CommitModelCount=Commit Model Count -static.UserIndex=User Index +static.UserIndex=Normalized user index +static.UserIndexPrimitive=User Index static.countdate=Count Date +static.FocusOtherUser=Focus Other User Count +static.CollectDataset=Collect Dataset Count +static.CollectedDataset=Collected Dataset Count +static.RecommendDataset=Recommended Dataset Count +static.CollectImage=Collect Image Count +static.CollectedImage=Collected Image Count +static.RecommendImage=Recommended Image Count static.all=All static.public.user_business_analysis_current_month=Current_Month static.public.user_business_analysis_current_week=Current_Week diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index c82347d5ea..27ba96c510 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -512,8 +512,16 @@ static.CloudBrainTaskNum=云脑任务数 static.CloudBrainRunTime=云脑运行时间(小时) static.CommitDatasetNum=上传(提交)数据集文件数 static.CommitModelCount=提交模型数 -static.UserIndex=用户指数 +static.UserIndex=归一化用户指数 +static.UserIndexPrimitive=用户指数 static.countdate=系统统计时间 +static.FocusOtherUser=关注他人数 +static.CollectDataset=收藏数据集 +static.CollectedDataset=被收藏数据集 +static.RecommendDataset=被推荐数据集数 +static.CollectImage=收藏镜像数 +static.CollectedImage=被收藏镜像数 +static.RecommendImage=被推荐镜像数 static.all=所有 static.public.user_business_analysis_current_month=本月 static.public.user_business_analysis_current_week=本周 diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 995465b09e..bfc85bb80c 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -19,6 +19,125 @@ const ( PAGE_SIZE = 2000 ) +func getExcelHeader(ctx *context.Context) map[string]string { + excelHeader := make([]string, 0) + excelHeader = append(excelHeader, ctx.Tr("user.static.id")) + excelHeader = append(excelHeader, ctx.Tr("user.static.name")) + excelHeader = append(excelHeader, ctx.Tr("user.static.UserIndex")) + excelHeader = append(excelHeader, ctx.Tr("user.static.UserIndexPrimitive")) + excelHeader = append(excelHeader, ctx.Tr("user.static.codemergecount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.commitcount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.issuecount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.commentcount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.focusrepocount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.starrepocount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.logincount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.watchedcount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.commitcodesize")) + excelHeader = append(excelHeader, ctx.Tr("user.static.solveissuecount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.encyclopediascount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.createrepocount")) + excelHeader = append(excelHeader, ctx.Tr("user.static.openiindex")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CloudBrainTaskNum")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CloudBrainRunTime")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CommitDatasetNum")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CommitModelCount")) + + excelHeader = append(excelHeader, ctx.Tr("user.static.FocusOtherUser")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CollectDataset")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CollectedDataset")) + excelHeader = append(excelHeader, ctx.Tr("user.static.RecommendDataset")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CollectImage")) + excelHeader = append(excelHeader, ctx.Tr("user.static.CollectedImage")) + excelHeader = append(excelHeader, ctx.Tr("user.static.RecommendImage")) + + excelHeader = append(excelHeader, ctx.Tr("user.static.registdate")) + excelHeader = append(excelHeader, ctx.Tr("user.static.countdate")) + + excelHeaderMap := make(map[string]string, 0) + var i, tmp byte + tmp = 'A' + i = 0 + for j, value := range excelHeader { + excelColumn := string(tmp+i) + fmt.Sprint(j+1) + log.Info("excelColumn=" + excelColumn) + excelHeaderMap[excelColumn] = value + i++ + } + return excelHeaderMap +} + +func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *models.UserBusinessAnalysisAll) { + rows := fmt.Sprint(row) + var tmp byte + tmp = 'A' + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.ID) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.Name) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndexPrimitive)) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CodeMergeCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.IssueCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommentCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.FocusRepoCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.StarRepoCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.LoginCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.WatchedCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitCodeSize) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.SolveIssueCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.EncyclopediasCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CreateRepoCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CloudBrainTaskNum) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitDatasetNum) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitModelCount) + tmp = tmp + 1 + + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.FocusOtherUser) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectDataset) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectedDataset) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.RecommendDataset) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectImage) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectedImage) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.RecommendImage) + tmp = tmp + 1 + + formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, formatTime[0:len(formatTime)-3]) + formatTime = userRecord.DataDate + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, string(tmp)+rows, formatTime) + +} + func queryUserDataPage(ctx *context.Context, tableName string, queryObj interface{}) { page := ctx.QueryInt("page") if page <= 0 { @@ -37,30 +156,7 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac sheetName := ctx.Tr("user.static.sheetname") index := xlsx.NewSheet(sheetName) xlsx.DeleteSheet("Sheet1") - dataHeader := map[string]string{ - "A1": ctx.Tr("user.static.id"), - "B1": ctx.Tr("user.static.name"), - "C1": ctx.Tr("user.static.UserIndex"), - "D1": ctx.Tr("user.static.codemergecount"), - "E1": ctx.Tr("user.static.commitcount"), - "F1": ctx.Tr("user.static.issuecount"), - "G1": ctx.Tr("user.static.commentcount"), - "H1": ctx.Tr("user.static.focusrepocount"), - "I1": ctx.Tr("user.static.starrepocount"), - "J1": ctx.Tr("user.static.logincount"), - "K1": ctx.Tr("user.static.watchedcount"), - "L1": ctx.Tr("user.static.commitcodesize"), - "M1": ctx.Tr("user.static.solveissuecount"), - "N1": ctx.Tr("user.static.encyclopediascount"), - "O1": ctx.Tr("user.static.createrepocount"), - "P1": ctx.Tr("user.static.openiindex"), - "Q1": ctx.Tr("user.static.CloudBrainTaskNum"), - "R1": ctx.Tr("user.static.CloudBrainRunTime"), - "S1": ctx.Tr("user.static.CommitDatasetNum"), - "T1": ctx.Tr("user.static.CommitModelCount"), - "U1": ctx.Tr("user.static.registdate"), - "V1": ctx.Tr("user.static.countdate"), - } + dataHeader := getExcelHeader(ctx) for k, v := range dataHeader { //设置单元格的值 xlsx.SetCellValue(sheetName, k, v) @@ -74,31 +170,32 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac log.Info("return count=" + fmt.Sprint(count)) for _, userRecord := range re { row++ - rows := fmt.Sprint(row) - xlsx.SetCellValue(sheetName, "A"+rows, userRecord.ID) - xlsx.SetCellValue(sheetName, "B"+rows, userRecord.Name) - xlsx.SetCellValue(sheetName, "C"+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) - xlsx.SetCellValue(sheetName, "D"+rows, userRecord.CodeMergeCount) - xlsx.SetCellValue(sheetName, "E"+rows, userRecord.CommitCount) - xlsx.SetCellValue(sheetName, "F"+rows, userRecord.IssueCount) - xlsx.SetCellValue(sheetName, "G"+rows, userRecord.CommentCount) - xlsx.SetCellValue(sheetName, "H"+rows, userRecord.FocusRepoCount) - xlsx.SetCellValue(sheetName, "I"+rows, userRecord.StarRepoCount) - xlsx.SetCellValue(sheetName, "J"+rows, userRecord.LoginCount) - xlsx.SetCellValue(sheetName, "K"+rows, userRecord.WatchedCount) - xlsx.SetCellValue(sheetName, "L"+rows, userRecord.CommitCodeSize) - xlsx.SetCellValue(sheetName, "M"+rows, userRecord.SolveIssueCount) - xlsx.SetCellValue(sheetName, "N"+rows, userRecord.EncyclopediasCount) - xlsx.SetCellValue(sheetName, "O"+rows, userRecord.CreateRepoCount) - xlsx.SetCellValue(sheetName, "P"+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) - xlsx.SetCellValue(sheetName, "Q"+rows, userRecord.CloudBrainTaskNum) - xlsx.SetCellValue(sheetName, "R"+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) - xlsx.SetCellValue(sheetName, "S"+rows, userRecord.CommitDatasetNum) - xlsx.SetCellValue(sheetName, "T"+rows, userRecord.CommitModelCount) - formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") - xlsx.SetCellValue(sheetName, "U"+rows, formatTime[0:len(formatTime)-3]) - formatTime = userRecord.DataDate - xlsx.SetCellValue(sheetName, "V"+rows, formatTime) + writeExcel(row, xlsx, sheetName, userRecord) + // rows := fmt.Sprint(row) + // xlsx.SetCellValue(sheetName, "A"+rows, userRecord.ID) + // xlsx.SetCellValue(sheetName, "B"+rows, userRecord.Name) + // xlsx.SetCellValue(sheetName, "C"+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) + // xlsx.SetCellValue(sheetName, "D"+rows, userRecord.CodeMergeCount) + // xlsx.SetCellValue(sheetName, "E"+rows, userRecord.CommitCount) + // xlsx.SetCellValue(sheetName, "F"+rows, userRecord.IssueCount) + // xlsx.SetCellValue(sheetName, "G"+rows, userRecord.CommentCount) + // xlsx.SetCellValue(sheetName, "H"+rows, userRecord.FocusRepoCount) + // xlsx.SetCellValue(sheetName, "I"+rows, userRecord.StarRepoCount) + // xlsx.SetCellValue(sheetName, "J"+rows, userRecord.LoginCount) + // xlsx.SetCellValue(sheetName, "K"+rows, userRecord.WatchedCount) + // xlsx.SetCellValue(sheetName, "L"+rows, userRecord.CommitCodeSize) + // xlsx.SetCellValue(sheetName, "M"+rows, userRecord.SolveIssueCount) + // xlsx.SetCellValue(sheetName, "N"+rows, userRecord.EncyclopediasCount) + // xlsx.SetCellValue(sheetName, "O"+rows, userRecord.CreateRepoCount) + // xlsx.SetCellValue(sheetName, "P"+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) + // xlsx.SetCellValue(sheetName, "Q"+rows, userRecord.CloudBrainTaskNum) + // xlsx.SetCellValue(sheetName, "R"+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) + // xlsx.SetCellValue(sheetName, "S"+rows, userRecord.CommitDatasetNum) + // xlsx.SetCellValue(sheetName, "T"+rows, userRecord.CommitModelCount) + // formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") + // xlsx.SetCellValue(sheetName, "U"+rows, formatTime[0:len(formatTime)-3]) + // formatTime = userRecord.DataDate + // xlsx.SetCellValue(sheetName, "V"+rows, formatTime) } indexTotal += PAGE_SIZE @@ -236,62 +333,40 @@ func QueryUserStaticDataPage(ctx *context.Context) { sheetName := ctx.Tr("user.static.sheetname") index := xlsx.NewSheet(sheetName) xlsx.DeleteSheet("Sheet1") - dataHeader := map[string]string{ - "A1": ctx.Tr("user.static.id"), - "B1": ctx.Tr("user.static.name"), - "C1": ctx.Tr("user.static.UserIndex"), - "D1": ctx.Tr("user.static.codemergecount"), - "E1": ctx.Tr("user.static.commitcount"), - "F1": ctx.Tr("user.static.issuecount"), - "G1": ctx.Tr("user.static.commentcount"), - "H1": ctx.Tr("user.static.focusrepocount"), - "I1": ctx.Tr("user.static.starrepocount"), - "J1": ctx.Tr("user.static.logincount"), - "K1": ctx.Tr("user.static.watchedcount"), - "L1": ctx.Tr("user.static.commitcodesize"), - "M1": ctx.Tr("user.static.solveissuecount"), - "N1": ctx.Tr("user.static.encyclopediascount"), - "O1": ctx.Tr("user.static.createrepocount"), - "P1": ctx.Tr("user.static.openiindex"), - "Q1": ctx.Tr("user.static.CloudBrainTaskNum"), - "R1": ctx.Tr("user.static.CloudBrainRunTime"), - "S1": ctx.Tr("user.static.CommitDatasetNum"), - "T1": ctx.Tr("user.static.CommitModelCount"), - "U1": ctx.Tr("user.static.registdate"), - "V1": ctx.Tr("user.static.countdate"), - } + + dataHeader := getExcelHeader(ctx) for k, v := range dataHeader { //设置单元格的值 xlsx.SetCellValue(sheetName, k, v) } for i, userRecord := range re { - rows := fmt.Sprint(i + 2) - - xlsx.SetCellValue(sheetName, "A"+rows, userRecord.ID) - xlsx.SetCellValue(sheetName, "B"+rows, userRecord.Name) - xlsx.SetCellValue(sheetName, "C"+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) - xlsx.SetCellValue(sheetName, "D"+rows, userRecord.CodeMergeCount) - xlsx.SetCellValue(sheetName, "E"+rows, userRecord.CommitCount) - xlsx.SetCellValue(sheetName, "F"+rows, userRecord.IssueCount) - xlsx.SetCellValue(sheetName, "G"+rows, userRecord.CommentCount) - xlsx.SetCellValue(sheetName, "H"+rows, userRecord.FocusRepoCount) - xlsx.SetCellValue(sheetName, "I"+rows, userRecord.StarRepoCount) - xlsx.SetCellValue(sheetName, "J"+rows, userRecord.LoginCount) - xlsx.SetCellValue(sheetName, "K"+rows, userRecord.WatchedCount) - xlsx.SetCellValue(sheetName, "L"+rows, userRecord.CommitCodeSize) - xlsx.SetCellValue(sheetName, "M"+rows, userRecord.SolveIssueCount) - xlsx.SetCellValue(sheetName, "N"+rows, userRecord.EncyclopediasCount) - xlsx.SetCellValue(sheetName, "O"+rows, userRecord.CreateRepoCount) - xlsx.SetCellValue(sheetName, "P"+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) - xlsx.SetCellValue(sheetName, "Q"+rows, userRecord.CloudBrainTaskNum) - xlsx.SetCellValue(sheetName, "R"+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) - xlsx.SetCellValue(sheetName, "S"+rows, userRecord.CommitDatasetNum) - xlsx.SetCellValue(sheetName, "T"+rows, userRecord.CommitModelCount) - formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") - xlsx.SetCellValue(sheetName, "U"+rows, formatTime[0:len(formatTime)-3]) - formatTime = userRecord.DataDate - xlsx.SetCellValue(sheetName, "V"+rows, formatTime) + row := i + 2 + writeExcel(row, xlsx, sheetName, userRecord) + // xlsx.SetCellValue(sheetName, "A"+rows, userRecord.ID) + // xlsx.SetCellValue(sheetName, "B"+rows, userRecord.Name) + // xlsx.SetCellValue(sheetName, "C"+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) + // xlsx.SetCellValue(sheetName, "D"+rows, userRecord.CodeMergeCount) + // xlsx.SetCellValue(sheetName, "E"+rows, userRecord.CommitCount) + // xlsx.SetCellValue(sheetName, "F"+rows, userRecord.IssueCount) + // xlsx.SetCellValue(sheetName, "G"+rows, userRecord.CommentCount) + // xlsx.SetCellValue(sheetName, "H"+rows, userRecord.FocusRepoCount) + // xlsx.SetCellValue(sheetName, "I"+rows, userRecord.StarRepoCount) + // xlsx.SetCellValue(sheetName, "J"+rows, userRecord.LoginCount) + // xlsx.SetCellValue(sheetName, "K"+rows, userRecord.WatchedCount) + // xlsx.SetCellValue(sheetName, "L"+rows, userRecord.CommitCodeSize) + // xlsx.SetCellValue(sheetName, "M"+rows, userRecord.SolveIssueCount) + // xlsx.SetCellValue(sheetName, "N"+rows, userRecord.EncyclopediasCount) + // xlsx.SetCellValue(sheetName, "O"+rows, userRecord.CreateRepoCount) + // xlsx.SetCellValue(sheetName, "P"+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) + // xlsx.SetCellValue(sheetName, "Q"+rows, userRecord.CloudBrainTaskNum) + // xlsx.SetCellValue(sheetName, "R"+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) + // xlsx.SetCellValue(sheetName, "S"+rows, userRecord.CommitDatasetNum) + // xlsx.SetCellValue(sheetName, "T"+rows, userRecord.CommitModelCount) + // formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") + // xlsx.SetCellValue(sheetName, "U"+rows, formatTime[0:len(formatTime)-3]) + // formatTime = userRecord.DataDate + // xlsx.SetCellValue(sheetName, "V"+rows, formatTime) } //设置默认打开的表单 diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 117984f959..c0e8c74112 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -64,13 +64,22 @@ + + + + + + + + + + + + + + + + + Date: Fri, 22 Apr 2022 11:45:12 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=85=B3=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index bfc85bb80c..63774877f8 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -58,9 +58,9 @@ func getExcelHeader(ctx *context.Context) map[string]string { var i, tmp byte tmp = 'A' i = 0 - for j, value := range excelHeader { - excelColumn := string(tmp+i) + fmt.Sprint(j+1) - log.Info("excelColumn=" + excelColumn) + for _, value := range excelHeader { + excelColumn := string(tmp+i) + fmt.Sprint(1) + //log.Info("excelColumn=" + excelColumn) excelHeaderMap[excelColumn] = value i++ } -- 2.34.1 From 6b06f4ce3207cdc139ab2b015e21fb842155402b Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 22 Apr 2022 17:48:34 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=85=B3=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 83 ++++++++++++++++-------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 63774877f8..6d43a815a3 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -55,12 +55,11 @@ func getExcelHeader(ctx *context.Context) map[string]string { excelHeader = append(excelHeader, ctx.Tr("user.static.countdate")) excelHeaderMap := make(map[string]string, 0) - var i, tmp byte - tmp = 'A' - i = 0 + + i := 0 for _, value := range excelHeader { - excelColumn := string(tmp+i) + fmt.Sprint(1) - //log.Info("excelColumn=" + excelColumn) + excelColumn := getColumn(i) + fmt.Sprint(1) + log.Info("excelColumn=" + excelColumn) excelHeaderMap[excelColumn] = value i++ } @@ -69,73 +68,77 @@ func getExcelHeader(ctx *context.Context) map[string]string { func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *models.UserBusinessAnalysisAll) { rows := fmt.Sprint(row) - var tmp byte - tmp = 'A' - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.ID) + tmp := 0 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.ID) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.Name) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Name) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndexPrimitive)) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndexPrimitive)) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CodeMergeCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CodeMergeCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.IssueCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.IssueCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommentCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommentCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.FocusRepoCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.FocusRepoCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.StarRepoCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.StarRepoCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.LoginCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.LoginCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.WatchedCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.WatchedCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitCodeSize) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitCodeSize) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.SolveIssueCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.SolveIssueCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.EncyclopediasCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.EncyclopediasCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CreateRepoCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CreateRepoCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CloudBrainTaskNum) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CloudBrainTaskNum) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitDatasetNum) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitDatasetNum) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CommitModelCount) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitModelCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.FocusOtherUser) - tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectDataset) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.FocusOtherUser) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectedDataset) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectDataset) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.RecommendDataset) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectedDataset) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectImage) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.RecommendDataset) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.CollectedImage) - tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, userRecord.RecommendImage) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectImage) tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectedImage) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.RecommendImage) + tmp = tmp + 1 formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, formatTime[0:len(formatTime)-3]) + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime[0:len(formatTime)-3]) formatTime = userRecord.DataDate tmp = tmp + 1 - xlsx.SetCellValue(sheetName, string(tmp)+rows, formatTime) - + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime) +} +func getColumn(tmp int) string { + if tmp < 26 { + return fmt.Sprint('A' + tmp) + } else { + return "A" + fmt.Sprint('A'+(tmp-26)) + } } func queryUserDataPage(ctx *context.Context, tableName string, queryObj interface{}) { -- 2.34.1 From 48229a6e7d9214e255b32eb2143f151b864d3a7d Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 22 Apr 2022 17:52:16 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=85=B3=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 6d43a815a3..0659916318 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -55,8 +55,8 @@ func getExcelHeader(ctx *context.Context) map[string]string { excelHeader = append(excelHeader, ctx.Tr("user.static.countdate")) excelHeaderMap := make(map[string]string, 0) - - i := 0 + var i byte + i = 0 for _, value := range excelHeader { excelColumn := getColumn(i) + fmt.Sprint(1) log.Info("excelColumn=" + excelColumn) @@ -68,7 +68,8 @@ func getExcelHeader(ctx *context.Context) map[string]string { func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *models.UserBusinessAnalysisAll) { rows := fmt.Sprint(row) - tmp := 0 + var tmp byte + tmp = 0 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.ID) tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Name) @@ -133,11 +134,13 @@ func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *mode tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime) } -func getColumn(tmp int) string { +func getColumn(tmp byte) string { + var tmpA byte + tmpA = 'A' if tmp < 26 { - return fmt.Sprint('A' + tmp) + return string(tmpA + tmp) } else { - return "A" + fmt.Sprint('A'+(tmp-26)) + return "A" + string(tmpA+(tmp-26)) } } -- 2.34.1 From b3f193d0c25027e0af7986bef37ae1aba0b5c645 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 22 Apr 2022 17:55:42 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=85=B3=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 0659916318..8dff133cfa 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -112,7 +112,6 @@ func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *mode tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitModelCount) tmp = tmp + 1 - xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.FocusOtherUser) tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectDataset) @@ -124,11 +123,10 @@ func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *mode xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectImage) tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectedImage) - + tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.RecommendImage) tmp = tmp + 1 formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") - tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime[0:len(formatTime)-3]) formatTime = userRecord.DataDate tmp = tmp + 1 -- 2.34.1 From adcb6af50adbb56e48d4bc7212ddf52c5754a121 Mon Sep 17 00:00:00 2001 From: zouap Date: Sun, 24 Apr 2022 09:50:19 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 52 ++---------------------------- 1 file changed, 2 insertions(+), 50 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 8dff133cfa..2280e82883 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -128,8 +128,9 @@ func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *mode tmp = tmp + 1 formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime[0:len(formatTime)-3]) - formatTime = userRecord.DataDate tmp = tmp + 1 + + formatTime = userRecord.DataDate xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime) } func getColumn(tmp byte) string { @@ -175,31 +176,6 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac for _, userRecord := range re { row++ writeExcel(row, xlsx, sheetName, userRecord) - // rows := fmt.Sprint(row) - // xlsx.SetCellValue(sheetName, "A"+rows, userRecord.ID) - // xlsx.SetCellValue(sheetName, "B"+rows, userRecord.Name) - // xlsx.SetCellValue(sheetName, "C"+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) - // xlsx.SetCellValue(sheetName, "D"+rows, userRecord.CodeMergeCount) - // xlsx.SetCellValue(sheetName, "E"+rows, userRecord.CommitCount) - // xlsx.SetCellValue(sheetName, "F"+rows, userRecord.IssueCount) - // xlsx.SetCellValue(sheetName, "G"+rows, userRecord.CommentCount) - // xlsx.SetCellValue(sheetName, "H"+rows, userRecord.FocusRepoCount) - // xlsx.SetCellValue(sheetName, "I"+rows, userRecord.StarRepoCount) - // xlsx.SetCellValue(sheetName, "J"+rows, userRecord.LoginCount) - // xlsx.SetCellValue(sheetName, "K"+rows, userRecord.WatchedCount) - // xlsx.SetCellValue(sheetName, "L"+rows, userRecord.CommitCodeSize) - // xlsx.SetCellValue(sheetName, "M"+rows, userRecord.SolveIssueCount) - // xlsx.SetCellValue(sheetName, "N"+rows, userRecord.EncyclopediasCount) - // xlsx.SetCellValue(sheetName, "O"+rows, userRecord.CreateRepoCount) - // xlsx.SetCellValue(sheetName, "P"+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) - // xlsx.SetCellValue(sheetName, "Q"+rows, userRecord.CloudBrainTaskNum) - // xlsx.SetCellValue(sheetName, "R"+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) - // xlsx.SetCellValue(sheetName, "S"+rows, userRecord.CommitDatasetNum) - // xlsx.SetCellValue(sheetName, "T"+rows, userRecord.CommitModelCount) - // formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") - // xlsx.SetCellValue(sheetName, "U"+rows, formatTime[0:len(formatTime)-3]) - // formatTime = userRecord.DataDate - // xlsx.SetCellValue(sheetName, "V"+rows, formatTime) } indexTotal += PAGE_SIZE @@ -347,30 +323,6 @@ func QueryUserStaticDataPage(ctx *context.Context) { for i, userRecord := range re { row := i + 2 writeExcel(row, xlsx, sheetName, userRecord) - // xlsx.SetCellValue(sheetName, "A"+rows, userRecord.ID) - // xlsx.SetCellValue(sheetName, "B"+rows, userRecord.Name) - // xlsx.SetCellValue(sheetName, "C"+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) - // xlsx.SetCellValue(sheetName, "D"+rows, userRecord.CodeMergeCount) - // xlsx.SetCellValue(sheetName, "E"+rows, userRecord.CommitCount) - // xlsx.SetCellValue(sheetName, "F"+rows, userRecord.IssueCount) - // xlsx.SetCellValue(sheetName, "G"+rows, userRecord.CommentCount) - // xlsx.SetCellValue(sheetName, "H"+rows, userRecord.FocusRepoCount) - // xlsx.SetCellValue(sheetName, "I"+rows, userRecord.StarRepoCount) - // xlsx.SetCellValue(sheetName, "J"+rows, userRecord.LoginCount) - // xlsx.SetCellValue(sheetName, "K"+rows, userRecord.WatchedCount) - // xlsx.SetCellValue(sheetName, "L"+rows, userRecord.CommitCodeSize) - // xlsx.SetCellValue(sheetName, "M"+rows, userRecord.SolveIssueCount) - // xlsx.SetCellValue(sheetName, "N"+rows, userRecord.EncyclopediasCount) - // xlsx.SetCellValue(sheetName, "O"+rows, userRecord.CreateRepoCount) - // xlsx.SetCellValue(sheetName, "P"+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) - // xlsx.SetCellValue(sheetName, "Q"+rows, userRecord.CloudBrainTaskNum) - // xlsx.SetCellValue(sheetName, "R"+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) - // xlsx.SetCellValue(sheetName, "S"+rows, userRecord.CommitDatasetNum) - // xlsx.SetCellValue(sheetName, "T"+rows, userRecord.CommitModelCount) - // formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") - // xlsx.SetCellValue(sheetName, "U"+rows, formatTime[0:len(formatTime)-3]) - // formatTime = userRecord.DataDate - // xlsx.SetCellValue(sheetName, "V"+rows, formatTime) } //设置默认打开的表单 -- 2.34.1