From 5bfef49ffe0968b78b3e8b122c6fda520382bd67 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 11 Jul 2022 15:30:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E5=B9=B6=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_analysis_for_activity.go | 1 + models/user_business_analysis.go | 11 +++++++++-- models/user_business_struct.go | 14 ++++++++++++++ options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + routers/repo/user_data_analysis.go | 14 ++++++++++++-- 6 files changed, 38 insertions(+), 4 deletions(-) diff --git a/models/user_analysis_for_activity.go b/models/user_analysis_for_activity.go index 7de5f0df1..f2c9e0a0c 100644 --- a/models/user_analysis_for_activity.go +++ b/models/user_analysis_for_activity.go @@ -81,6 +81,7 @@ func QueryDataForActivity(startTime time.Time, endTime time.Time) []*UserBusines dateRecord.ID = userRecord.ID log.Info("i=" + fmt.Sprint(i) + " userName=" + userRecord.Name) dateRecord.Email = userRecord.Email + dateRecord.Phone = userRecord.PhoneNumber dateRecord.RegistDate = userRecord.CreatedUnix dateRecord.Name = userRecord.Name diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 84b220f11..7e667d675 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -105,6 +105,8 @@ type UserBusinessAnalysisAll struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + Phone string `xorm:"NOT NULL"` } type UserBusinessAnalysis struct { @@ -192,6 +194,8 @@ type UserBusinessAnalysis struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + Phone string `xorm:"NOT NULL"` } type UserBusinessAnalysisQueryOptions struct { @@ -475,6 +479,7 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi dateRecord.CountDate = CountDate.Unix() dateRecord.DataDate = DataDate dateRecord.Email = userRecord.Email + dateRecord.Phone = userRecord.PhoneNumber dateRecord.RegistDate = userRecord.CreatedUnix dateRecord.Name = userRecord.Name dateRecord.UserLocation = userRecord.Location @@ -728,6 +733,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS var dateRecordAll UserBusinessAnalysisAll dateRecordAll.ID = userRecord.ID dateRecordAll.Email = userRecord.Email + dateRecordAll.Phone = userRecord.PhoneNumber dateRecordAll.RegistDate = userRecord.CreatedUnix dateRecordAll.Name = userRecord.Name dateRecordAll.GiteaAgeMonth = subMonth(currentTimeNow, userRecord.CreatedUnix.AsTime()) @@ -839,7 +845,7 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static insertBatchSql := "INSERT INTO public." + tableName + "(id, count_date, code_merge_count, commit_count, issue_count, comment_count, focus_repo_count, star_repo_count, watched_count, gitea_age_month, commit_code_size, commit_dataset_size, " + - "commit_model_count, solve_issue_count, encyclopedias_count, regist_date, create_repo_count, login_count, open_i_index, email, name, data_date,cloud_brain_task_num,gpu_debug_job,npu_debug_job,gpu_train_job,npu_train_job,npu_inference_job,gpu_bench_mark_job,cloud_brain_run_time,commit_dataset_num,user_index,user_location,focus_other_user,collect_dataset,collected_dataset,recommend_dataset,collect_image,collected_image,recommend_image,user_index_primitive) " + + "commit_model_count, solve_issue_count, encyclopedias_count, regist_date, create_repo_count, login_count, open_i_index, email, name, data_date,cloud_brain_task_num,gpu_debug_job,npu_debug_job,gpu_train_job,npu_train_job,npu_inference_job,gpu_bench_mark_job,cloud_brain_run_time,commit_dataset_num,user_index,user_location,focus_other_user,collect_dataset,collected_dataset,recommend_dataset,collect_image,collected_image,recommend_image,user_index_primitive,phone) " + "VALUES" for i, record := range dateRecords { @@ -848,7 +854,7 @@ func insertTable(dateRecords []UserBusinessAnalysisAll, tableName string, static ", " + fmt.Sprint(record.WatchedCount) + ", " + fmt.Sprint(record.GiteaAgeMonth) + ", " + fmt.Sprint(record.CommitCodeSize) + ", " + fmt.Sprint(record.CommitDatasetSize) + ", " + fmt.Sprint(record.CommitModelCount) + ", " + fmt.Sprint(record.SolveIssueCount) + ", " + fmt.Sprint(record.EncyclopediasCount) + ", " + fmt.Sprint(record.RegistDate) + ", " + fmt.Sprint(record.CreateRepoCount) + ", " + fmt.Sprint(record.LoginCount) + ", " + fmt.Sprint(record.OpenIIndex) + ", '" + record.Email + "', '" + record.Name + "', '" + record.DataDate + "'," + fmt.Sprint(record.CloudBrainTaskNum) + "," + fmt.Sprint(record.GpuDebugJob) + "," + fmt.Sprint(record.NpuDebugJob) + "," + fmt.Sprint(record.GpuTrainJob) + "," + fmt.Sprint(record.NpuTrainJob) + "," + fmt.Sprint(record.NpuInferenceJob) + "," + fmt.Sprint(record.GpuBenchMarkJob) + "," + fmt.Sprint(record.CloudBrainRunTime) + "," + fmt.Sprint(record.CommitDatasetNum) + "," + fmt.Sprint(record.UserIndex) + ",'" + record.UserLocation + "'," + - fmt.Sprint(record.FocusOtherUser) + "," + fmt.Sprint(record.CollectDataset) + "," + fmt.Sprint(record.CollectedDataset) + "," + fmt.Sprint(record.RecommendDataset) + "," + fmt.Sprint(record.CollectImage) + "," + fmt.Sprint(record.CollectedImage) + "," + fmt.Sprint(record.RecommendImage) + "," + fmt.Sprint(record.UserIndexPrimitive) + ")" + fmt.Sprint(record.FocusOtherUser) + "," + fmt.Sprint(record.CollectDataset) + "," + fmt.Sprint(record.CollectedDataset) + "," + fmt.Sprint(record.RecommendDataset) + "," + fmt.Sprint(record.CollectImage) + "," + fmt.Sprint(record.CollectedImage) + "," + fmt.Sprint(record.RecommendImage) + "," + fmt.Sprint(record.UserIndexPrimitive) + ",'" + record.Phone + "')" if i < (len(dateRecords) - 1) { insertBatchSql += "," } @@ -973,6 +979,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.CountDate = CountDate.Unix() dateRecord.Email = userRecord.Email + dateRecord.Phone = userRecord.PhoneNumber dateRecord.RegistDate = userRecord.CreatedUnix dateRecord.Name = userRecord.Name dateRecord.GiteaAgeMonth = subMonth(currentTimeNow, userRecord.CreatedUnix.AsTime()) diff --git a/models/user_business_struct.go b/models/user_business_struct.go index 870a64bc7..9cadbed0b 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -65,6 +65,8 @@ type UserBusinessAnalysisCurrentYear struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + Phone string `xorm:"NOT NULL"` } type UserBusinessAnalysisLast30Day struct { @@ -130,6 +132,8 @@ type UserBusinessAnalysisLast30Day struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + Phone string `xorm:"NOT NULL"` } type UserBusinessAnalysisLastMonth struct { @@ -195,6 +199,8 @@ type UserBusinessAnalysisLastMonth struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + Phone string `xorm:"NOT NULL"` } type UserBusinessAnalysisCurrentMonth struct { @@ -260,6 +266,8 @@ type UserBusinessAnalysisCurrentMonth struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + Phone string `xorm:"NOT NULL"` } type UserBusinessAnalysisCurrentWeek struct { @@ -326,6 +334,8 @@ type UserBusinessAnalysisCurrentWeek struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + Phone string `xorm:"NOT NULL"` } type UserBusinessAnalysisYesterday struct { @@ -392,6 +402,8 @@ type UserBusinessAnalysisYesterday struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + Phone string `xorm:"NOT NULL"` } type UserBusinessAnalysisLastWeek struct { @@ -458,6 +470,8 @@ type UserBusinessAnalysisLastWeek struct { CollectImage int `xorm:"NOT NULL DEFAULT 0"` CollectedImage int `xorm:"NOT NULL DEFAULT 0"` RecommendImage int `xorm:"NOT NULL DEFAULT 0"` + + Phone string `xorm:"NOT NULL"` } type UserAnalysisPara struct { diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 2efaafdc9..0c9852c12 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -559,6 +559,7 @@ static.CollectImage=Collect Image Count static.CollectedImage=Collected Image Count static.RecommendImage=Recommended Image Count static.email=Email +static.phone=Phone static.location=Location static.all=All static.public.user_business_analysis_current_month=Current_Month diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index fe91aaed3..350d0800d 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -564,6 +564,7 @@ static.CollectImage=收藏镜像数 static.CollectedImage=被收藏镜像数 static.RecommendImage=被推荐镜像数 static.email=Email +static.phone=电话 static.location=所在地区 static.all=所有 static.public.user_business_analysis_current_month=本月 diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index db0cea97c..cc8d3dced 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -112,6 +112,7 @@ func getExcelHeader(ctx *context.Context) map[string]string { excelHeader = append(excelHeader, ctx.Tr("user.static.RecommendImage")) excelHeader = append(excelHeader, ctx.Tr("user.static.email")) + excelHeader = append(excelHeader, ctx.Tr("user.static.phone")) excelHeader = append(excelHeader, ctx.Tr("user.static.location")) excelHeader = append(excelHeader, ctx.Tr("user.static.registdate")) @@ -193,6 +194,9 @@ func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *mode xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Email) tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Phone) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.UserLocation) tmp = tmp + 1 @@ -268,6 +272,9 @@ func writeExcelPage(row int, xlsx *excelize.File, sheetName string, userRecord * xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Email) tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Phone) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.UserLocation) tmp = tmp + 1 @@ -723,8 +730,8 @@ func TimingCountData() { } func QueryUserActivity(ctx *context.Context) { - startDate := ctx.Query("startDate") - endDate := ctx.Query("endDate") + startDate := ctx.Query("beginTime") + endDate := ctx.Query("endTime") t, _ := time.Parse("2006-01-02", startDate) startTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location()) @@ -768,6 +775,7 @@ func writeUserActivityToExcel(startTime time.Time, endTime time.Time, filePath s excelHeader = append(excelHeader, ctx.Tr("user.static.CommitDatasetNum")) excelHeader = append(excelHeader, ctx.Tr("user.static.CommitModelCount")) excelHeader = append(excelHeader, ctx.Tr("user.static.email")) + excelHeader = append(excelHeader, ctx.Tr("user.static.phone")) excelHeader = append(excelHeader, ctx.Tr("user.static.registdate")) excelHeaderMap := make(map[string]string, 0) @@ -814,6 +822,8 @@ func writeUserActivityToExcel(startTime time.Time, endTime time.Time, filePath s tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Email) tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Phone) + tmp = tmp + 1 formatTime := userRecord.RegistDate.Format("2006-01-02 15:04:05") xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime[0:len(formatTime)-3]) tmp = tmp + 1