From 3a8ef92720553d350cf7b294d746e5debd7c9918 Mon Sep 17 00:00:00 2001 From: liuzx Date: Mon, 16 May 2022 15:36:17 +0800 Subject: [PATCH 01/96] fix-2050 --- routers/repo/cloudbrain.go | 6 +++--- routers/repo/modelarts.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index b3b07f352..0ef6a6cb6 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -204,7 +204,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { ctx.Data["PageIsCloudBrain"] = true displayJobName := form.DisplayJobName jobName := util.ConvertDisplayJobNameToJobName(displayJobName) - image := form.Image + image := strings.TrimSpace(form.Image) uuid := form.Attachment jobType := form.JobType gpuQueue := form.GpuType @@ -1816,7 +1816,7 @@ func CloudBrainBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainF ctx.Data["PageIsCloudBrain"] = true displayJobName := form.DisplayJobName jobName := util.ConvertDisplayJobNameToJobName(displayJobName) - image := form.Image + image := strings.TrimSpace(form.Image) gpuQueue := form.GpuType command := cloudbrain.CommandBenchmark codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath @@ -1998,7 +1998,7 @@ func CloudBrainTrainJobNew(ctx *context.Context) { func getTrainJobCommand(form auth.CreateCloudBrainForm) (string, error) { var command string - bootFile := form.BootFile + bootFile := strings.TrimSpace(form.BootFile) params := form.Params if !strings.HasSuffix(bootFile, ".py") { diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 81e1664a4..c5a4de645 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -967,7 +967,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) description := form.Description workServerNumber := form.WorkServerNumber engineID := form.EngineID - bootFile := form.BootFile + bootFile := strings.TrimSpace(form.BootFile) flavorCode := form.Flavor params := form.Params poolID := form.PoolID @@ -1210,7 +1210,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ description := form.Description workServerNumber := form.WorkServerNumber engineID := form.EngineID - bootFile := form.BootFile + bootFile := strings.TrimSpace(form.BootFile) flavorCode := form.Flavor params := form.Params poolID := form.PoolID @@ -1803,7 +1803,7 @@ func InferenceJobCreate(ctx *context.Context, form auth.CreateModelArtsInference description := form.Description workServerNumber := form.WorkServerNumber engineID := form.EngineID - bootFile := form.BootFile + bootFile := strings.TrimSpace(form.BootFile) flavorCode := form.Flavor params := form.Params poolID := form.PoolID From c104a4d90e3caf83bd557442188f2be7d340415f Mon Sep 17 00:00:00 2001 From: liuzx Date: Mon, 16 May 2022 15:55:54 +0800 Subject: [PATCH 02/96] fix-2021 --- routers/repo/modelarts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 81e1664a4..4ba7dc3ba 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -1284,7 +1284,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ var parameters models.Parameters param := make([]models.Parameter, 0) - existDeviceTarget := true + existDeviceTarget := false if len(params) != 0 { err := json.Unmarshal([]byte(params), ¶meters) if err != nil { From 82f6f123cac81a2ba1d4971d33d3cdd1f843e61c Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 23 May 2022 09:18:47 +0800 Subject: [PATCH 03/96] fix-2054 --- models/org.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/org.go b/models/org.go index 2a6528023..c956f1f89 100755 --- a/models/org.go +++ b/models/org.go @@ -160,7 +160,11 @@ func UpdateOrgStatistics() { has, _ := x.Get(orgStat) orgStat.NumScore = numScore - if has { + + count, err := GetPublicRepositoryCount(&org) + if err != nil || count == 0 { + x.ID(orgStat.ID).Delete(new(OrgStatistic)) + } else if has { x.ID(orgStat.ID).Cols("num_score").Update(&orgStat) } else { x.Insert(orgStat) From 65b7220a839355e38c4ff60a2233fa3b7b7e0b13 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 23 May 2022 09:38:22 +0800 Subject: [PATCH 04/96] fix-2048 --- models/dataset.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index d3a142742..d4a7748d3 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -1,10 +1,12 @@ package models import ( - "code.gitea.io/gitea/modules/log" "errors" "fmt" "sort" + "strings" + + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" "xorm.io/builder" @@ -179,7 +181,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { func generateFilterCond(opts *SearchDatasetOptions, cond builder.Cond) builder.Cond { if len(opts.Keyword) > 0 { - cond = cond.And(builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) + cond = cond.And(builder.Or(builder.Like{"LOWER(dataset.title)", strings.ToLower(opts.Keyword)}, builder.Like{"LOWER(dataset.description)", strings.ToLower(opts.Keyword)})) } if len(opts.Category) > 0 { From b8b829327cbbb77db13120098dd3d6be7591bfac Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 23 May 2022 09:52:09 +0800 Subject: [PATCH 05/96] =?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 --- routers/repo/cloudbrain.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 12d254812..68264708c 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -482,6 +482,17 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo ctx.Data["resource_type"] = resourceType.Value } } + } else if cloudbrain.IsBenchmarkJob(task.JobType) { + if benchmarkGpuInfos == nil { + json.Unmarshal([]byte(setting.BenchmarkGpuTypes), &benchmarkGpuInfos) + } + + for _, resourceType := range benchmarkGpuInfos.GpuInfo { + if resourceType.Queue == jobRes.Config.GpuType { + ctx.Data["resource_type"] = resourceType.Value + } + } + } else { if gpuInfos == nil { json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) From 7ea98940a408cd7410d1621e97a7fa9403e822cb Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 10:28:21 +0800 Subject: [PATCH 06/96] =?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 | 134 +++++++++++++++++++++++++++++-------- 1 file changed, 106 insertions(+), 28 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 1bebb9f3e..56a88856f 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -186,6 +186,75 @@ func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *mode formatTime = userRecord.DataDate xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime) } + +func writeExcelPage(row int, xlsx *excelize.File, sheetName string, userRecord *models.UserBusinessAnalysis) { + rows := fmt.Sprint(row) + var tmp byte + tmp = 0 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.ID) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Name) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndex)) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", userRecord.UserIndexPrimitive)) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CodeMergeCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.IssueCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommentCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.FocusRepoCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.StarRepoCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.LoginCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.WatchedCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitCodeSize) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.SolveIssueCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.EncyclopediasCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CreateRepoCount) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CloudBrainTaskNum) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, fmt.Sprintf("%.2f", float64(userRecord.CloudBrainRunTime)/3600)) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CommitDatasetNum) + 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) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.CollectedDataset) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.RecommendDataset) + tmp = tmp + 1 + 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") + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime[0:len(formatTime)-3]) + tmp = tmp + 1 + + formatTime = userRecord.DataDate + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime) +} + func getColumn(tmp byte) string { var tmpA byte tmpA = 'A' @@ -481,36 +550,13 @@ func QueryUserStaticDataPage(ctx *context.Context) { } if IsReturnFile { - re, count := models.QueryUserStaticDataAll(pageOpts) - log.Info("return count=" + fmt.Sprint(count)) - //writer exec file. - xlsx := excelize.NewFile() + //re, count := models.QueryUserStaticDataAll(pageOpts) + re, count := models.QueryUserStaticDataPage(pageOpts) sheetName := ctx.Tr("user.static.sheetname") - index := xlsx.NewSheet(sheetName) - xlsx.DeleteSheet("Sheet1") - - dataHeader := getExcelHeader(ctx) - for k, v := range dataHeader { - //设置单元格的值 - xlsx.SetCellValue(sheetName, k, v) - } - - for i, userRecord := range re { - row := i + 2 - writeExcel(row, xlsx, sheetName, userRecord) - } - - //设置默认打开的表单 - xlsx.SetActiveSheet(index) - - filename := sheetName + "_" + ctx.Tr("user.static.all") + ".xlsx" - - ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename)) - ctx.Resp.Header().Set("Content-Type", "application/octet-stream") - if _, err := xlsx.WriteTo(ctx.Resp); err != nil { - log.Info("writer exel error." + err.Error()) - } + filename := sheetName + "_" + startDate + "_" + endDate + ".xlsx" + go writeFileToDisk(ctx, count, re, filename) + ctx.JSON(http.StatusOK, filename) } else { mapInterface := make(map[string]interface{}) re, count := models.QueryUserStaticDataPage(pageOpts) @@ -520,6 +566,38 @@ func QueryUserStaticDataPage(ctx *context.Context) { } } +func writeFileToDisk(ctx *context.Context, count int64, re []*models.UserBusinessAnalysis, filename string) { + log.Info("return count=" + fmt.Sprint(count)) + //writer exec file. + xlsx := excelize.NewFile() + sheetName := ctx.Tr("user.static.sheetname") + index := xlsx.NewSheet(sheetName) + xlsx.DeleteSheet("Sheet1") + + dataHeader := getExcelHeader(ctx) + for k, v := range dataHeader { + //设置单元格的值 + xlsx.SetCellValue(sheetName, k, v) + } + + for i, userRecord := range re { + row := i + 2 + writeExcelPage(row, xlsx, sheetName, userRecord) + } + + //设置默认打开的表单 + xlsx.SetActiveSheet(index) + + //ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename)) + //ctx.Resp.Header().Set("Content-Type", "application/octet-stream") + filename = setting.AppDataPath + "/useranalysis/" + filename + if err := xlsx.SaveAs(filename); err != nil { + log.Info("writer exel error." + err.Error()) + } else { + log.Info("write to file succeed, filepath=" + filename) + } +} + func TimingCountDataByDateAndReCount(date string, isReCount bool) { t, _ := time.Parse("2006-01-02", date) From c6f085cc795d22ec7bd753343879eb3b8b67587a Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 23 May 2022 10:44:21 +0800 Subject: [PATCH 07/96] fix-1482 --- routers/repo/dataset.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 73036a2cc..619967ab6 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -106,6 +106,8 @@ func DatasetIndex(ctx *context.Context) { MustEnableDataset(ctx) ctx.Data["PageIsDataset"] = true + ctx.Data["SortType"] = ctx.Query("sort") + repo := ctx.Repo.Repository dataset, err := models.GetDatasetByRepo(repo) @@ -128,9 +130,15 @@ func DatasetIndex(ctx *context.Context) { attachments := newFilterPrivateAttachments(ctx, dataset.Attachments, repo) - sort.Slice(attachments, func(i, j int) bool { - return attachments[i].CreatedUnix > attachments[j].CreatedUnix - }) + if ctx.Data["SortType"] == "name" { + sort.Slice(attachments, func(i, j int) bool { + return strings.ToLower(attachments[i].Name) < strings.ToLower(attachments[j].Name) + }) + } else { + sort.Slice(attachments, func(i, j int) bool { + return attachments[i].CreatedUnix > attachments[j].CreatedUnix + }) + } page := ctx.QueryInt("page") if page <= 0 { From 859f5ed7a18361ea71a997b25eaff1fb9139b11f Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 10:53:57 +0800 Subject: [PATCH 08/96] =?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/api/v1/api.go | 1 + routers/repo/user_data_analysis.go | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index d2c6e3633..8bf12c9d0 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -559,6 +559,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/query_metrics_all", operationReq, repo_ext.QueryUserMetricsAll) m.Get("/query_user_metrics_page", operationReq, repo_ext.QueryUserMetricDataPage) + m.Get("/download_user_define_file", operationReq, repo_ext.DownloadUserDefineFile) m.Get("/query_user_rank_list", operationReq, repo_ext.QueryRankingList) m.Get("/query_user_static_page", operationReq, repo_ext.QueryUserStaticDataPage) m.Get("/query_user_current_month", operationReq, repo_ext.QueryUserStaticCurrentMonth) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 56a88856f..15032df6b 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "net/url" + "os" "time" "code.gitea.io/gitea/models" @@ -16,7 +17,8 @@ import ( ) const ( - PAGE_SIZE = 2000 + PAGE_SIZE = 2000 + Excel_File_Path = "/useranalysis/" ) func getUserMetricsExcelHeader(ctx *context.Context) map[string]string { @@ -399,6 +401,25 @@ func QueryRankingList(ctx *context.Context) { ctx.JSON(http.StatusOK, mapInterface) } +func DownloadUserDefineFile(ctx *context.Context) { + filename := ctx.Query("filename") + length := len(filename) + if filename[0:1] == "\"" { + filename = filename[1 : length-1] + } + allFilename := setting.AppDataPath + Excel_File_Path + filename + log.Info("allFilename=" + allFilename) + _, err := os.Stat(allFilename) + if err != nil { //文件不存在 + log.Info("file not exist.") + ctx.JSON(http.StatusOK, "File Not Exist.") + } else { + ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+filename) + ctx.Resp.Header().Set("Content-Type", "application/octet-stream") + ctx.ServeFile(allFilename, filename) + } +} + func QueryUserMetricsCurrentMonth(ctx *context.Context) { currentTimeNow := time.Now() @@ -590,7 +611,8 @@ func writeFileToDisk(ctx *context.Context, count int64, re []*models.UserBusines //ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(filename)) //ctx.Resp.Header().Set("Content-Type", "application/octet-stream") - filename = setting.AppDataPath + "/useranalysis/" + filename + filename = setting.AppDataPath + Excel_File_Path + filename + os.Mkdir(setting.AppDataPath+Excel_File_Path, 0755) if err := xlsx.SaveAs(filename); err != nil { log.Info("writer exel error." + err.Error()) } else { From 8e6fcafca3f0742f0486584c1eb5cb262762df75 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 11:00:48 +0800 Subject: [PATCH 09/96] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 15032df6b..fa2d43589 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -577,7 +577,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { filename := sheetName + "_" + startDate + "_" + endDate + ".xlsx" go writeFileToDisk(ctx, count, re, filename) - ctx.JSON(http.StatusOK, filename) + ctx.Redirect("/api/v1/download_user_define_file?filename=" + filename) } else { mapInterface := make(map[string]interface{}) re, count := models.QueryUserStaticDataPage(pageOpts) From f648f0982788e59d5d2d4c0766fc5e49fa29d330 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 11:05:42 +0800 Subject: [PATCH 10/96] =?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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index fa2d43589..4042955ec 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -575,9 +575,9 @@ func QueryUserStaticDataPage(ctx *context.Context) { re, count := models.QueryUserStaticDataPage(pageOpts) sheetName := ctx.Tr("user.static.sheetname") filename := sheetName + "_" + startDate + "_" + endDate + ".xlsx" - + os.Remove(setting.AppDataPath + Excel_File_Path + filename) go writeFileToDisk(ctx, count, re, filename) - ctx.Redirect("/api/v1/download_user_define_file?filename=" + filename) + ctx.JSON(http.StatusOK, filename) } else { mapInterface := make(map[string]interface{}) re, count := models.QueryUserStaticDataPage(pageOpts) From 0689e0047650ef28b0d6d0e5a818ed33e328b214 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 11:08:04 +0800 Subject: [PATCH 11/96] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 4042955ec..5d2e336fd 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -577,7 +577,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { filename := sheetName + "_" + startDate + "_" + endDate + ".xlsx" os.Remove(setting.AppDataPath + Excel_File_Path + filename) go writeFileToDisk(ctx, count, re, filename) - ctx.JSON(http.StatusOK, filename) + ctx.JSON(http.StatusOK, setting.AppURL+"/api/v1/download_user_define_file?filename="+filename) } else { mapInterface := make(map[string]interface{}) re, count := models.QueryUserStaticDataPage(pageOpts) From 821d9088431864405e144589aba8fbffc5dc8e76 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 11:09:35 +0800 Subject: [PATCH 12/96] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 5d2e336fd..e0c72da57 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -577,7 +577,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { filename := sheetName + "_" + startDate + "_" + endDate + ".xlsx" os.Remove(setting.AppDataPath + Excel_File_Path + filename) go writeFileToDisk(ctx, count, re, filename) - ctx.JSON(http.StatusOK, setting.AppURL+"/api/v1/download_user_define_file?filename="+filename) + ctx.JSON(http.StatusOK, setting.AppURL+"api/v1/download_user_define_file?filename="+filename) } else { mapInterface := make(map[string]interface{}) re, count := models.QueryUserStaticDataPage(pageOpts) From 1d4be6af12a80ac948f4aef54ca600f527d098c2 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 11:32:02 +0800 Subject: [PATCH 13/96] =?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/custom_migrations.go | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/models/custom_migrations.go b/models/custom_migrations.go index d0158530b..412bedce1 100644 --- a/models/custom_migrations.go +++ b/models/custom_migrations.go @@ -1,8 +1,6 @@ package models import ( - "fmt" - "code.gitea.io/gitea/modules/log" "xorm.io/xorm" ) @@ -22,7 +20,6 @@ var customMigrations = []CustomMigration{ } var customMigrationsStatic = []CustomMigrationStatic{ - {"Delete organization user history data ", deleteNotDisplayUser}, {"update issue_fixed_rate to 1 if num_issues is 0 ", updateIssueFixedRate}, } @@ -36,7 +33,6 @@ func MigrateCustom(x *xorm.Engine) { } } - } func MigrateCustomStatic(x *xorm.Engine, static *xorm.Engine) { @@ -58,24 +54,6 @@ func syncTopicStruct(x *xorm.Engine) error { return err } -func deleteNotDisplayUser(x *xorm.Engine, static *xorm.Engine) error { - - querySQL := "select id,name from public.user where type=1" - rows, err := x.Query(querySQL) - if err != nil { - log.Info("select db failed,err:", err) - return err - } - - for i, userRow := range rows { - log.Info("delete zuzi user, i=" + fmt.Sprint(i) + " userName=" + string(userRow["name"])) - deleteSql := "delete from user_business_analysis where id=" + string(userRow["id"]) + " and name='" + string(userRow["name"]) + "'" - static.Exec(deleteSql) - } - - return nil -} - func updateIssueFixedRate(x *xorm.Engine, static *xorm.Engine) error { updateSQL := "update repo_statistic set issue_fixed_rate=1.0 where num_issues=0" _, err := static.Exec(updateSQL) From d90706658f4345008ec978b6694be9eb026508bf Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 11:58:33 +0800 Subject: [PATCH 14/96] =?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 | 59 ++++++++++++++++++++++++++++++++++++++ routers/repo/user_data_analysis.go | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 56e591dea..02317198a 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -407,6 +407,65 @@ func QueryUserStaticDataAll(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusi return userBusinessAnalysisReturnList, allCount } +func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { + log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime) + " isAll=" + fmt.Sprint(opts.IsAll)) + statictisSess := xStatistic.NewSession() + defer statictisSess.Close() + var cond = builder.NewCond() + cond = cond.And( + builder.Gte{"count_date": opts.StartTime}, + ) + cond = cond.And( + builder.Lte{"count_date": opts.EndTime}, + ) + count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) + if err != nil { + log.Info("query error." + err.Error()) + return nil, 0 + } + resultMap := make(map[int64]*UserBusinessAnalysis) + if count > 0 { + pageSize := 1000 + totalPage := int(count) / pageSize + for i := 0; i <= int(totalPage); i++ { + userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) + if err := statictisSess.Table("user_business_analysis").Where(cond).OrderBy("count_date desc").Limit(pageSize, i*pageSize). + Find(&userBusinessAnalysisList); err != nil { + return nil, 0 + } + log.Info("query result size=" + fmt.Sprint(len(userBusinessAnalysisList))) + for _, userRecord := range userBusinessAnalysisList { + if _, ok := resultMap[userRecord.ID]; !ok { + resultMap[userRecord.ID] = userRecord + } else { + resultMap[userRecord.ID].CodeMergeCount += userRecord.CodeMergeCount + resultMap[userRecord.ID].CommitCount += userRecord.CommitCount + resultMap[userRecord.ID].IssueCount += userRecord.IssueCount + resultMap[userRecord.ID].CommentCount += userRecord.CommentCount + resultMap[userRecord.ID].FocusRepoCount += userRecord.FocusRepoCount + resultMap[userRecord.ID].StarRepoCount += userRecord.StarRepoCount + resultMap[userRecord.ID].WatchedCount += userRecord.WatchedCount + resultMap[userRecord.ID].CommitCodeSize += userRecord.CommitCodeSize + resultMap[userRecord.ID].CommitDatasetSize += userRecord.CommitDatasetSize + resultMap[userRecord.ID].CommitDatasetNum += userRecord.CommitDatasetNum + resultMap[userRecord.ID].CommitModelCount += userRecord.CommitModelCount + resultMap[userRecord.ID].SolveIssueCount += userRecord.SolveIssueCount + resultMap[userRecord.ID].EncyclopediasCount += userRecord.EncyclopediasCount + resultMap[userRecord.ID].CreateRepoCount += userRecord.CreateRepoCount + resultMap[userRecord.ID].LoginCount += userRecord.LoginCount + } + } + } + } + userBusinessAnalysisReturnList := UserBusinessAnalysisList{} + for _, v := range resultMap { + userBusinessAnalysisReturnList = append(userBusinessAnalysisReturnList, v) + } + sort.Sort(userBusinessAnalysisReturnList) + log.Info("return size=" + fmt.Sprint(len(userBusinessAnalysisReturnList))) + return userBusinessAnalysisReturnList, count +} + func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime) + " isAll=" + fmt.Sprint(opts.IsAll)) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index e0c72da57..1f03fbf44 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -572,7 +572,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { if IsReturnFile { //re, count := models.QueryUserStaticDataAll(pageOpts) - re, count := models.QueryUserStaticDataPage(pageOpts) + re, count := models.QueryUserStaticDataForUserDefine(pageOpts) sheetName := ctx.Tr("user.static.sheetname") filename := sheetName + "_" + startDate + "_" + endDate + ".xlsx" os.Remove(setting.AppDataPath + Excel_File_Path + filename) From 3efb1697f1c15b5b5576ae9ce8dc52205dafd1bc Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 15:01:25 +0800 Subject: [PATCH 15/96] =?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/models.go | 1 + models/user_business_analysis.go | 178 +++++++++++++++++++++++---------- models/user_business_struct.go | 66 ++++++++++++ options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + routers/api/v1/api.go | 1 + routers/repo/user_data_analysis.go | 37 ++++--- web_src/js/components/UserAnalysis.vue | 6 ++ 8 files changed, 225 insertions(+), 66 deletions(-) diff --git a/models/models.go b/models/models.go index 2a2e119fb..9d255c5e6 100755 --- a/models/models.go +++ b/models/models.go @@ -157,6 +157,7 @@ func init() { new(UserBusinessAnalysisCurrentMonth), new(UserBusinessAnalysisCurrentWeek), new(UserBusinessAnalysisYesterday), + new(UserBusinessAnalysisLastWeek), new(UserLoginLog), new(UserMetrics), new(UserAnalysisPara), diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 02317198a..b986baab5 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -407,63 +407,132 @@ func QueryUserStaticDataAll(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusi return userBusinessAnalysisReturnList, allCount } -func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { - log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime) + " isAll=" + fmt.Sprint(opts.IsAll)) - statictisSess := xStatistic.NewSession() - defer statictisSess.Close() - var cond = builder.NewCond() - cond = cond.And( - builder.Gte{"count_date": opts.StartTime}, - ) - cond = cond.And( - builder.Lte{"count_date": opts.EndTime}, - ) - count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) +func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wikiCountMap map[string]int) ([]*UserBusinessAnalysis, int64) { + log.Info("start to count other user info data") + sess := x.NewSession() + defer sess.Close() + + currentTimeNow := time.Now() + log.Info("current time:" + currentTimeNow.Format("2006-01-02 15:04:05")) + + start_unix := opts.StartTime + + end_unix := opts.EndTime + CountDate := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 1, 0, 0, currentTimeNow.Location()) + + CodeMergeCountMap := queryPullRequest(start_unix, end_unix) + CommitCountMap := queryCommitAction(start_unix, end_unix, 5) + IssueCountMap := queryCreateIssue(start_unix, end_unix) + + CommentCountMap := queryComment(start_unix, end_unix) + FocusRepoCountMap := queryWatch(start_unix, end_unix) + StarRepoCountMap := queryStar(start_unix, end_unix) + WatchedCountMap, WatchOtherMap := queryFollow(start_unix, end_unix) + + CommitCodeSizeMap, err := GetAllUserKPIStats() if err != nil { - log.Info("query error." + err.Error()) - return nil, 0 + log.Info("query commit code errr.") + } else { + log.Info("query commit code size, len=" + fmt.Sprint(len(CommitCodeSizeMap))) + CommitCodeSizeMapJson, _ := json.Marshal(CommitCodeSizeMap) + log.Info("CommitCodeSizeMapJson=" + string(CommitCodeSizeMapJson)) } - resultMap := make(map[int64]*UserBusinessAnalysis) - if count > 0 { - pageSize := 1000 - totalPage := int(count) / pageSize - for i := 0; i <= int(totalPage); i++ { - userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) - if err := statictisSess.Table("user_business_analysis").Where(cond).OrderBy("count_date desc").Limit(pageSize, i*pageSize). - Find(&userBusinessAnalysisList); err != nil { - return nil, 0 + CommitDatasetSizeMap, CommitDatasetNumMap := queryDatasetSize(start_unix, end_unix) + SolveIssueCountMap := querySolveIssue(start_unix, end_unix) + CreateRepoCountMap := queryUserCreateRepo(start_unix, end_unix) + LoginCountMap := queryLoginCount(start_unix, end_unix) + 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() + + cond := "type != 1 and and is_active=true" + count, err := sess.Where(cond).Count(new(User)) + + ParaWeight := getParaWeight() + ResultList := make([]*UserBusinessAnalysis, 0) + var indexTotal int64 + indexTotal = 0 + for { + sess.Select("`user`.*").Table("user").Where(cond).OrderBy("id asc").Limit(PAGE_SIZE, int(indexTotal)) + userList := make([]*User, 0) + sess.Find(&userList) + + for i, userRecord := range userList { + var dateRecord UserBusinessAnalysis + dateRecord.ID = userRecord.ID + log.Info("i=" + fmt.Sprint(i) + " userName=" + userRecord.Name) + dateRecord.CountDate = CountDate.Unix() + + dateRecord.Email = userRecord.Email + dateRecord.RegistDate = userRecord.CreatedUnix + dateRecord.Name = userRecord.Name + dateRecord.GiteaAgeMonth = subMonth(currentTimeNow, userRecord.CreatedUnix.AsTime()) + + dateRecord.CodeMergeCount = getMapValue(dateRecord.ID, CodeMergeCountMap) + dateRecord.CommitCount = getMapValue(dateRecord.ID, CommitCountMap) + dateRecord.IssueCount = getMapValue(dateRecord.ID, IssueCountMap) + dateRecord.CommentCount = getMapValue(dateRecord.ID, CommentCountMap) + 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) } - log.Info("query result size=" + fmt.Sprint(len(userBusinessAnalysisList))) - for _, userRecord := range userBusinessAnalysisList { - if _, ok := resultMap[userRecord.ID]; !ok { - resultMap[userRecord.ID] = userRecord - } else { - resultMap[userRecord.ID].CodeMergeCount += userRecord.CodeMergeCount - resultMap[userRecord.ID].CommitCount += userRecord.CommitCount - resultMap[userRecord.ID].IssueCount += userRecord.IssueCount - resultMap[userRecord.ID].CommentCount += userRecord.CommentCount - resultMap[userRecord.ID].FocusRepoCount += userRecord.FocusRepoCount - resultMap[userRecord.ID].StarRepoCount += userRecord.StarRepoCount - resultMap[userRecord.ID].WatchedCount += userRecord.WatchedCount - resultMap[userRecord.ID].CommitCodeSize += userRecord.CommitCodeSize - resultMap[userRecord.ID].CommitDatasetSize += userRecord.CommitDatasetSize - resultMap[userRecord.ID].CommitDatasetNum += userRecord.CommitDatasetNum - resultMap[userRecord.ID].CommitModelCount += userRecord.CommitModelCount - resultMap[userRecord.ID].SolveIssueCount += userRecord.SolveIssueCount - resultMap[userRecord.ID].EncyclopediasCount += userRecord.EncyclopediasCount - resultMap[userRecord.ID].CreateRepoCount += userRecord.CreateRepoCount - resultMap[userRecord.ID].LoginCount += userRecord.LoginCount - } + dateRecord.CommitDatasetSize = getMapValue(dateRecord.ID, CommitDatasetSizeMap) + dateRecord.CommitDatasetNum = getMapValue(dateRecord.ID, CommitDatasetNumMap) + dateRecord.SolveIssueCount = getMapValue(dateRecord.ID, SolveIssueCountMap) + + dateRecord.EncyclopediasCount = getMapKeyStringValue(dateRecord.Name, wikiCountMap) + + dateRecord.CreateRepoCount = getMapValue(dateRecord.ID, CreateRepoCountMap) + + dateRecord.LoginCount = getMapValue(dateRecord.ID, LoginCountMap) + + if _, ok := OpenIIndexMap[dateRecord.ID]; !ok { + dateRecord.OpenIIndex = 0 + } else { + dateRecord.OpenIIndex = OpenIIndexMap[dateRecord.ID] } + + dateRecord.CloudBrainTaskNum = getMapValue(dateRecord.ID, CloudBrainTaskMap) + dateRecord.GpuDebugJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuDebugJob", CloudBrainTaskItemMap) + dateRecord.NpuDebugJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_NpuDebugJob", CloudBrainTaskItemMap) + dateRecord.GpuTrainJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_GpuTrainJob", CloudBrainTaskItemMap) + dateRecord.NpuTrainJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_NpuTrainJob", CloudBrainTaskItemMap) + dateRecord.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecord.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) + 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.UserIndexPrimitive = getUserIndex(dateRecord, ParaWeight) + ResultList = append(ResultList, &dateRecord) + } + + indexTotal += PAGE_SIZE + if indexTotal >= count { + break } } - userBusinessAnalysisReturnList := UserBusinessAnalysisList{} - for _, v := range resultMap { - userBusinessAnalysisReturnList = append(userBusinessAnalysisReturnList, v) - } - sort.Sort(userBusinessAnalysisReturnList) - log.Info("return size=" + fmt.Sprint(len(userBusinessAnalysisReturnList))) - return userBusinessAnalysisReturnList, count + + return ResultList, int64(len(ResultList)) } func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { @@ -792,7 +861,12 @@ func RefreshUserStaticAllTabel(wikiCountMap map[string]int, userMetrics map[stri pageStartTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset) refreshUserStaticTable(wikiCountMap, "user_business_analysis_current_week", pageStartTime, pageEndTime, userMetrics) + pageEndTime = pageStartTime + pageStartTime = pageStartTime.AddDate(0, 0, -7) + refreshUserStaticTable(wikiCountMap, "user_business_analysis_last_week", pageStartTime, pageEndTime, userMetrics) + pageStartTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -30) + pageEndTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) refreshUserStaticTable(wikiCountMap, "user_business_analysis_last30_day", pageStartTime, pageEndTime, userMetrics) pageStartTime = time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, -1) @@ -937,7 +1011,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, log.Info("has activity." + userRecord.Name) addUserToMap(userNewAddActivity, userRecord.CreatedUnix, dateRecord.ID) } - if userRecord.IsActive { + if !userRecord.IsActive { continue } statictisSess.Delete(&dateRecord) diff --git a/models/user_business_struct.go b/models/user_business_struct.go index 70f806c78..fec361bca 100644 --- a/models/user_business_struct.go +++ b/models/user_business_struct.go @@ -394,6 +394,72 @@ type UserBusinessAnalysisYesterday struct { RecommendImage int `xorm:"NOT NULL DEFAULT 0"` } +type UserBusinessAnalysisLastWeek struct { + ID int64 `xorm:"pk"` + CountDate int64 `xorm:"pk"` + //action :ActionMergePullRequest // 11 + CodeMergeCount int `xorm:"NOT NULL DEFAULT 0"` + //action :ActionCommitRepo + CommitCount int `xorm:"NOT NULL DEFAULT 0"` + //issue // 10 + IssueCount int `xorm:"NOT NULL DEFAULT 0"` + //comment table current date + CommentCount int `xorm:"NOT NULL DEFAULT 0"` + //watch table current date + FocusRepoCount int `xorm:"NOT NULL DEFAULT 0"` + //star table current date + StarRepoCount int `xorm:"NOT NULL DEFAULT 0"` + //follow table + WatchedCount int `xorm:"NOT NULL DEFAULT 0"` + // user table + GiteaAgeMonth int `xorm:"NOT NULL DEFAULT 0"` + // + CommitCodeSize int `xorm:"NOT NULL DEFAULT 0"` + //attachement table + CommitDatasetSize int `xorm:"NOT NULL DEFAULT 0"` + //0 + CommitModelCount int `xorm:"NOT NULL DEFAULT 0"` + //issue, issueassignees + SolveIssueCount int `xorm:"NOT NULL DEFAULT 0"` + //baike + EncyclopediasCount int `xorm:"NOT NULL DEFAULT 0"` + //user + RegistDate timeutil.TimeStamp `xorm:"NOT NULL"` + //repo + CreateRepoCount int `xorm:"NOT NULL DEFAULT 0"` + //login count, from elk + LoginCount int `xorm:"NOT NULL DEFAULT 0"` + //openi index + OpenIIndex float64 `xorm:"NOT NULL DEFAULT 0"` + //user + Email string `xorm:"NOT NULL"` + //user + 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"` + UserIndexPrimitive float64 `xorm:"NOT NULL DEFAULT 0"` + + UserLocation string `xorm:"NULL"` + + FocusOtherUser int `xorm:"NOT NULL DEFAULT 0"` + CollectDataset int `xorm:"NOT NULL DEFAULT 0"` + CollectedDataset int `xorm:"NOT NULL DEFAULT 0"` + RecommendDataset int `xorm:"NOT NULL DEFAULT 0"` + CollectImage int `xorm:"NOT NULL DEFAULT 0"` + CollectedImage int `xorm:"NOT NULL DEFAULT 0"` + RecommendImage int `xorm:"NOT NULL DEFAULT 0"` +} + type UserAnalysisPara struct { Key string `xorm:"NOT NULL"` Value float64 `xorm:"NOT NULL DEFAULT 0"` diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index ef3ad7705..265e7ed36 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -522,6 +522,7 @@ 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 +static.public.user_business_analysis_last_week=Last_Week static.public.user_business_analysis_current_year=Current_Year static.public.user_business_analysis_last30_day=Last_30_day static.public.user_business_analysis_last_month=Last_Month diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 2f0bbe91d..1b26a930c 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -527,6 +527,7 @@ static.RecommendImage=被推荐镜像数 static.all=所有 static.public.user_business_analysis_current_month=本月 static.public.user_business_analysis_current_week=本周 +static.public.user_business_analysis_last_week=上周 static.public.user_business_analysis_current_year=今年 static.public.user_business_analysis_last30_day=近30天 static.public.user_business_analysis_last_month=上月 diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 8bf12c9d0..03f13b195 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -564,6 +564,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/query_user_static_page", operationReq, repo_ext.QueryUserStaticDataPage) m.Get("/query_user_current_month", operationReq, repo_ext.QueryUserStaticCurrentMonth) m.Get("/query_user_current_week", operationReq, repo_ext.QueryUserStaticCurrentWeek) + m.Get("/query_user_last_week", operationReq, repo_ext.QueryUserStaticCurrentWeek) m.Get("/query_user_current_year", operationReq, repo_ext.QueryUserStaticCurrentYear) m.Get("/query_user_last30_day", operationReq, repo_ext.QueryUserStaticLast30Day) m.Get("/query_user_last_month", operationReq, repo_ext.QueryUserStaticLastMonth) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 1f03fbf44..65764d58a 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -455,6 +455,10 @@ func QueryUserMetricsCurrentWeek(ctx *context.Context) { func QueryUserStaticCurrentWeek(ctx *context.Context) { queryUserDataPage(ctx, "public.user_business_analysis_current_week", new(models.UserBusinessAnalysisCurrentWeek)) } +func QueryUserStaticLastWeek(ctx *context.Context) { + queryUserDataPage(ctx, "public.user_business_analysis_last_week", new(models.UserBusinessAnalysisLastWeek)) +} + func QueryUserMetricsCurrentYear(ctx *context.Context) { currentTimeNow := time.Now() pageStartTime := time.Date(currentTimeNow.Year(), 1, 1, 0, 0, 0, 0, currentTimeNow.Location()) @@ -572,7 +576,8 @@ func QueryUserStaticDataPage(ctx *context.Context) { if IsReturnFile { //re, count := models.QueryUserStaticDataAll(pageOpts) - re, count := models.QueryUserStaticDataForUserDefine(pageOpts) + wikiMap, _ := queryWikiCountMap(startTime, endTime) + re, count := models.QueryUserStaticDataForUserDefine(pageOpts, wikiMap) sheetName := ctx.Tr("user.static.sheetname") filename := sheetName + "_" + startDate + "_" + endDate + ".xlsx" os.Remove(setting.AppDataPath + Excel_File_Path + filename) @@ -620,22 +625,14 @@ func writeFileToDisk(ctx *context.Context, count int64, re []*models.UserBusines } } -func TimingCountDataByDateAndReCount(date string, isReCount bool) { - - t, _ := time.Parse("2006-01-02", date) - startTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location()) - - endTime := time.Date(t.Year(), t.Month(), t.Day(), 23, 59, 59, 0, t.Location()) - - //query wiki data - log.Info("start to time count data") +func queryWikiCountMap(startTime time.Time, endTime time.Time) (map[string]int, error) { wikiMap := make(map[string]int) warnEmailMessage := "用户统计信息入库失败,请尽快定位。" repoList, err := models.GetAllRepositories() if err != nil { log.Error("query repo error." + err.Error()) mailer.SendWarnNotifyMail(setting.Warn_Notify_Mails, warnEmailMessage) - return + return nil, err } log.Info("start to query wiki data") for _, repoRecord := range repoList { @@ -643,7 +640,7 @@ func TimingCountDataByDateAndReCount(date string, isReCount bool) { time, err := git.GetLatestCommitTime(wikiPath) if err == nil { log.Info("last commit time:" + time.Format("2006-01-02 15:04:05") + " wikiPath=" + wikiPath) - if time.After(startTime) { + if time.After(startTime) && time.Before(endTime) { wikiRepo, _, err := FindWikiRepoCommitByWikiPath(wikiPath) if err != nil { log.Error("wiki not exist. wikiPath=" + wikiPath) @@ -668,14 +665,26 @@ func TimingCountDataByDateAndReCount(date string, isReCount bool) { } } } + return wikiMap, nil +} + +func TimingCountDataByDateAndReCount(date string, isReCount bool) { + + t, _ := time.Parse("2006-01-02", date) + startTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location()) + + endTime := time.Date(t.Year(), t.Month(), t.Day(), 23, 59, 59, 0, t.Location()) + warnEmailMessage := "用户统计信息入库失败,请尽快定位。" + //query wiki data + log.Info("start to time count data") + wikiMap, err := queryWikiCountMap(startTime, endTime) //other user info data err = models.CounDataByDateAndReCount(wikiMap, startTime, endTime, isReCount) if err != nil { log.Error("count user info error." + err.Error()) mailer.SendWarnNotifyMail(setting.Warn_Notify_Mails, warnEmailMessage) } - log.Info("start to count all user info data") - //models.RefreshUserStaticAllTabel(wikiMap) + log.Info("end to count all user info data") } diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 784d375fb..4d48bd3b6 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -7,6 +7,7 @@ 统计周期: + @@ -375,6 +376,11 @@ this.dataUrl = '../../api/v1/query_user_current_week'; break } + case "last_week_usr":{ + this.value_time=[] + this.dataUrl = '../../api/v1/query_user_last_week'; + break + } case "current_month_usr":{ this.value_time=[] this.dataUrl = '../../api/v1/query_user_current_month'; From f3dffd7db87110b24fa4cb3c61cc91297a06a04e Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 15:09:05 +0800 Subject: [PATCH 16/96] =?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/models.go | 2 +- models/user_business_analysis.go | 8 ++++---- routers/repo/user_data_analysis.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/models/models.go b/models/models.go index 9d255c5e6..46444c58b 100755 --- a/models/models.go +++ b/models/models.go @@ -157,7 +157,7 @@ func init() { new(UserBusinessAnalysisCurrentMonth), new(UserBusinessAnalysisCurrentWeek), new(UserBusinessAnalysisYesterday), - new(UserBusinessAnalysisLastWeek), + //new(UserBusinessAnalysisLastWeek), new(UserLoginLog), new(UserMetrics), new(UserAnalysisPara), diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index b986baab5..2984fdc3f 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -407,7 +407,7 @@ func QueryUserStaticDataAll(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusi return userBusinessAnalysisReturnList, allCount } -func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wikiCountMap map[string]int) ([]*UserBusinessAnalysis, int64) { +func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wikiCountMap map[string]int) ([]UserBusinessAnalysis, int64) { log.Info("start to count other user info data") sess := x.NewSession() defer sess.Close() @@ -457,7 +457,7 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi count, err := sess.Where(cond).Count(new(User)) ParaWeight := getParaWeight() - ResultList := make([]*UserBusinessAnalysis, 0) + ResultList := make([]UserBusinessAnalysis, 0) var indexTotal int64 indexTotal = 0 for { @@ -523,7 +523,7 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi dateRecord.RecommendImage = getMapValue(dateRecord.ID, RecommendImage) dateRecord.UserIndexPrimitive = getUserIndex(dateRecord, ParaWeight) - ResultList = append(ResultList, &dateRecord) + ResultList = append(ResultList, dateRecord) } indexTotal += PAGE_SIZE @@ -531,7 +531,7 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi break } } - + log.Info("query user define,count=" + fmt.Sprint((ResultList))) return ResultList, int64(len(ResultList)) } diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 65764d58a..430c8b2cc 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -189,7 +189,7 @@ func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *mode xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime) } -func writeExcelPage(row int, xlsx *excelize.File, sheetName string, userRecord *models.UserBusinessAnalysis) { +func writeExcelPage(row int, xlsx *excelize.File, sheetName string, userRecord models.UserBusinessAnalysis) { rows := fmt.Sprint(row) var tmp byte tmp = 0 @@ -592,7 +592,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { } } -func writeFileToDisk(ctx *context.Context, count int64, re []*models.UserBusinessAnalysis, filename string) { +func writeFileToDisk(ctx *context.Context, count int64, re []models.UserBusinessAnalysis, filename string) { log.Info("return count=" + fmt.Sprint(count)) //writer exec file. xlsx := excelize.NewFile() From 16ad0e80426449ba13f868871dce6a30eef68904 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 15:12:40 +0800 Subject: [PATCH 17/96] =?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 | 8 ++++---- routers/repo/user_data_analysis.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 2984fdc3f..1dadb8e64 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -407,7 +407,7 @@ func QueryUserStaticDataAll(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusi return userBusinessAnalysisReturnList, allCount } -func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wikiCountMap map[string]int) ([]UserBusinessAnalysis, int64) { +func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wikiCountMap map[string]int) ([]*UserBusinessAnalysis, int64) { log.Info("start to count other user info data") sess := x.NewSession() defer sess.Close() @@ -453,11 +453,11 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi statictisSess := xStatistic.NewSession() defer statictisSess.Close() - cond := "type != 1 and and is_active=true" + cond := "type != 1 and is_active=true" count, err := sess.Where(cond).Count(new(User)) ParaWeight := getParaWeight() - ResultList := make([]UserBusinessAnalysis, 0) + ResultList := make([]*UserBusinessAnalysis, 0) var indexTotal int64 indexTotal = 0 for { @@ -523,7 +523,7 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi dateRecord.RecommendImage = getMapValue(dateRecord.ID, RecommendImage) dateRecord.UserIndexPrimitive = getUserIndex(dateRecord, ParaWeight) - ResultList = append(ResultList, dateRecord) + ResultList = append(ResultList, &dateRecord) } indexTotal += PAGE_SIZE diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 430c8b2cc..65764d58a 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -189,7 +189,7 @@ func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *mode xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, formatTime) } -func writeExcelPage(row int, xlsx *excelize.File, sheetName string, userRecord models.UserBusinessAnalysis) { +func writeExcelPage(row int, xlsx *excelize.File, sheetName string, userRecord *models.UserBusinessAnalysis) { rows := fmt.Sprint(row) var tmp byte tmp = 0 @@ -592,7 +592,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { } } -func writeFileToDisk(ctx *context.Context, count int64, re []models.UserBusinessAnalysis, filename string) { +func writeFileToDisk(ctx *context.Context, count int64, re []*models.UserBusinessAnalysis, filename string) { log.Info("return count=" + fmt.Sprint(count)) //writer exec file. xlsx := excelize.NewFile() From 516aa059244e033e2892966e73cfbe9b778a2c08 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 15:15:47 +0800 Subject: [PATCH 18/96] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 65764d58a..f631591d1 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -551,7 +551,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { startDate = settingStartTime.Format("2006-01-02") } endTime, _ = time.ParseInLocation("2006-01-02", endDate, time.Local) - endTime = endTime.AddDate(0, 0, 1) + //endTime = endTime.AddDate(0, 0, 1) endTime = time.Date(endTime.Year(), endTime.Month(), endTime.Day(), 23, 59, 59, 0, startTime.Location()) isAll = false From 4a2c126a7272e4c4e1713b0088d6af840afcc5bd Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 15:16:42 +0800 Subject: [PATCH 19/96] =?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 --- web_src/js/components/UserAnalysis.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 4d48bd3b6..587784712 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -7,7 +7,6 @@ 统计周期: - From df2603806fdf8b9cac2643b3cd4e5ebc7fc71372 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 15:26:08 +0800 Subject: [PATCH 20/96] =?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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 1dadb8e64..a6caaa733 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -541,9 +541,9 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus statictisSess := xStatistic.NewSession() defer statictisSess.Close() - currentTimeNow := time.Now() - pageStartTime := getLastCountDate() - pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()).Unix() + //currentTimeNow := time.Now() + //pageStartTime := getLastCountDate() + //pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()).Unix() var cond = builder.NewCond() if len(opts.UserName) > 0 { @@ -552,10 +552,10 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus ) } cond = cond.And( - builder.Gte{"count_date": pageStartTime}, + builder.Gte{"count_date": opts.StartTime}, ) cond = cond.And( - builder.Lte{"count_date": pageEndTime}, + builder.Lte{"count_date": opts.EndTime}, ) count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) From 07bba7e8b88149c5399b813cc009bfa7ebcf2bb5 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 15:28:22 +0800 Subject: [PATCH 21/96] =?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 --- web_src/js/components/UserAnalysis.vue | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 587784712..d67daac46 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -27,11 +27,9 @@ - - + - 下载报告 - 下载报告 + 下载报告 From d9f1aa156e609c6f638c24c45c7b63250bc70866 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 15:35:08 +0800 Subject: [PATCH 22/96] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index a6caaa733..59a9268ba 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -575,7 +575,7 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus } userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) - if err := statictisSess.Table("user_business_analysis").Where(cond).OrderBy("id desc"). + if err := statictisSess.Table("user_business_analysis").Where(cond).OrderBy("count_date,id desc"). Find(&userBusinessAnalysisList); err != nil { return nil, 0 } From 645bde4ff378d6b16cd901263eb2420b037ae61a Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 15:42:15 +0800 Subject: [PATCH 23/96] =?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 --- web_src/js/components/UserAnalysis.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index d67daac46..587784712 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -27,9 +27,11 @@ - + + - 下载报告 + 下载报告 + 下载报告 From 195c2811433f6f684c62c4d7215222e90c698002 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 23 May 2022 15:51:24 +0800 Subject: [PATCH 24/96] =?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 --- routers/repo/dataset.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 619967ab6..0e57fe1a0 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -130,10 +130,26 @@ func DatasetIndex(ctx *context.Context) { attachments := newFilterPrivateAttachments(ctx, dataset.Attachments, repo) - if ctx.Data["SortType"] == "name" { + if ctx.Data["SortType"] == "nameAsc" { sort.Slice(attachments, func(i, j int) bool { return strings.ToLower(attachments[i].Name) < strings.ToLower(attachments[j].Name) }) + } else if ctx.Data["SortType"] == "nameDesc" { + sort.Slice(attachments, func(i, j int) bool { + return strings.ToLower(attachments[i].Name) > strings.ToLower(attachments[j].Name) + }) + } else if ctx.Data["SortType"] == "sizeAsc" { + sort.Slice(attachments, func(i, j int) bool { + return attachments[i].Size < attachments[j].Size + }) + } else if ctx.Data["SortType"] == "sizeDesc" { + sort.Slice(attachments, func(i, j int) bool { + return attachments[i].Size > attachments[j].Size + }) + } else if ctx.Data["SortType"] == "timeAsc" { + sort.Slice(attachments, func(i, j int) bool { + return attachments[i].CreatedUnix < attachments[j].CreatedUnix + }) } else { sort.Slice(attachments, func(i, j int) bool { return attachments[i].CreatedUnix > attachments[j].CreatedUnix From eac3bc9dbf14eb903f2a4b7f991be84c3675c09a Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 16:42:21 +0800 Subject: [PATCH 25/96] =?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/models.go | 2 +- models/repo_activity_custom.go | 4 ++-- models/user_business_analysis.go | 23 +++++++++++++++++++---- modules/git/repo_stats_custom.go | 19 +++++++++++++------ 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/models/models.go b/models/models.go index 46444c58b..9d255c5e6 100755 --- a/models/models.go +++ b/models/models.go @@ -157,7 +157,7 @@ func init() { new(UserBusinessAnalysisCurrentMonth), new(UserBusinessAnalysisCurrentWeek), new(UserBusinessAnalysisYesterday), - //new(UserBusinessAnalysisLastWeek), + new(UserBusinessAnalysisLastWeek), new(UserLoginLog), new(UserMetrics), new(UserAnalysisPara), diff --git a/models/repo_activity_custom.go b/models/repo_activity_custom.go index ac39a8de7..cbe00b9d9 100644 --- a/models/repo_activity_custom.go +++ b/models/repo_activity_custom.go @@ -211,7 +211,7 @@ func setKeyContributerDict(contributorDistinctDict map[string]int, email string, } } -func GetAllUserKPIStats() (map[string]*git.UserKPIStats, error) { +func GetAllUserKPIStats(startTime time.Time, endTime time.Time) (map[string]*git.UserKPIStats, error) { authors := make(map[string]*git.UserKPIStats) repositorys, err := GetAllRepositoriesByFilterCols("owner_name", "name") if err != nil { @@ -219,7 +219,7 @@ func GetAllUserKPIStats() (map[string]*git.UserKPIStats, error) { } for _, repository := range repositorys { - authorsOneRepo, err1 := git.GetUserKPIStats(repository.RepoPath()) + authorsOneRepo, err1 := git.GetUserKPIStats(repository.RepoPath(), startTime, endTime) if err1 != nil { log.Warn("get user kpi status err:"+repository.RepoPath(), err1.Error()) continue diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 59a9268ba..177b1caba 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -429,7 +429,9 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi StarRepoCountMap := queryStar(start_unix, end_unix) WatchedCountMap, WatchOtherMap := queryFollow(start_unix, end_unix) - CommitCodeSizeMap, err := GetAllUserKPIStats() + StartTime := time.Unix(start_unix, 0) + EndTime := time.Unix(end_unix, 0) + CommitCodeSizeMap, err := GetAllUserKPIStats(StartTime, EndTime) if err != nil { log.Info("query commit code errr.") } else { @@ -679,7 +681,15 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS FocusRepoCountMap := queryWatch(start_unix, end_unix) StarRepoCountMap := queryStar(start_unix, end_unix) WatchedCountMap, WatchOtherMap := queryFollow(start_unix, end_unix) - CommitCodeSizeMap := queryCommitCodeSize(StartTimeNextDay.Unix(), EndTimeNextDay.Unix()) + CommitCodeSizeMap, err := GetAllUserKPIStats(StartTimeNextDay, EndTimeNextDay) + if err != nil { + log.Info("query commit code errr.") + } else { + log.Info("query commit code size, len=" + fmt.Sprint(len(CommitCodeSizeMap))) + CommitCodeSizeMapJson, _ := json.Marshal(CommitCodeSizeMap) + log.Info("CommitCodeSizeMapJson=" + string(CommitCodeSizeMapJson)) + } + //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) @@ -733,7 +743,12 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS dateRecordAll.FocusOtherUser = getMapValue(dateRecordAll.ID, WatchOtherMap) dateRecordAll.StarRepoCount = getMapValue(dateRecordAll.ID, StarRepoCountMap) dateRecordAll.WatchedCount = getMapValue(dateRecordAll.ID, WatchedCountMap) - dateRecordAll.CommitCodeSize = getMapValue(dateRecordAll.ID, CommitCodeSizeMap) + if _, ok := CommitCodeSizeMap[dateRecordAll.Email]; !ok { + dateRecordAll.CommitCodeSize = 0 + } else { + dateRecordAll.CommitCodeSize = int(CommitCodeSizeMap[dateRecordAll.Email].CommitLines) + } + //dateRecordAll.CommitCodeSize = getMapValue(dateRecordAll.ID, CommitCodeSizeMap) dateRecordAll.CommitDatasetSize = getMapValue(dateRecordAll.ID, CommitDatasetSizeMap) dateRecordAll.CommitDatasetNum = getMapValue(dateRecordAll.ID, CommitDatasetNumMap) dateRecordAll.SolveIssueCount = getMapValue(dateRecordAll.ID, SolveIssueCountMap) @@ -907,7 +922,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, StarRepoCountMap := queryStar(start_unix, end_unix) WatchedCountMap, WatchOtherMap := queryFollow(start_unix, end_unix) - CommitCodeSizeMap, err := GetAllUserKPIStats() + CommitCodeSizeMap, err := GetAllUserKPIStats(startTime, endTime) if err != nil { log.Info("query commit code errr.") } else { diff --git a/modules/git/repo_stats_custom.go b/modules/git/repo_stats_custom.go index d70a17052..1a7b657d5 100644 --- a/modules/git/repo_stats_custom.go +++ b/modules/git/repo_stats_custom.go @@ -58,12 +58,11 @@ func SetDevelopAge(repoPath string, stats *RepoKPIStats, fromTime time.Time) err return nil } -//获取一天内的用户贡献指标 -func GetUserKPIStats(repoPath string) (map[string]*UserKPIStats, error) { - timeUntil := time.Now() - oneDayAgo := timeUntil.AddDate(0, 0, -1) - since := oneDayAgo.Format(time.RFC3339) - args := []string{"log", "--numstat", "--no-merges", "--branches=*", "--pretty=format:---%n%h%n%an%n%ae%n", "--date=iso", fmt.Sprintf("--since='%s'", since)} +func GetUserKPIStats(repoPath string, startTime time.Time, endTime time.Time) (map[string]*UserKPIStats, error) { + + after := startTime.Format(time.RFC3339) + until := endTime.Format(time.RFC3339) + args := []string{"log", "--numstat", "--no-merges", "--branches=*", "--pretty=format:---%n%h%n%an%n%ae%n", "--date=iso", fmt.Sprintf("--after='%s'", after), fmt.Sprintf("--until=='%s'", until)} stdout, err := NewCommand(args...).RunInDirBytes(repoPath) if err != nil { return nil, err @@ -124,6 +123,14 @@ func GetUserKPIStats(repoPath string) (map[string]*UserKPIStats, error) { } +//获取一天内的用户贡献指标 +func getUserKPIStats(repoPath string) (map[string]*UserKPIStats, error) { + timeUntil := time.Now() + oneDayAgo := timeUntil.AddDate(0, 0, -1) + + return GetUserKPIStats(repoPath, oneDayAgo, oneDayAgo) +} + func SetRepoKPIStats(repoPath string, fromTime time.Time, stats *RepoKPIStats, newContributers map[string]struct{}) error { since := fromTime.Format(time.RFC3339) args := []string{"log", "--numstat", "--no-merges", "HEAD", "--pretty=format:---%n%h%n%an%n%ae%n", "--date=iso", fmt.Sprintf("--since='%s'", since)} From 141762edff7bd683fc477aa2b6b43aa4b89d77ed Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 16:46:16 +0800 Subject: [PATCH 26/96] =?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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 177b1caba..dd50cb964 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -419,6 +419,7 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi end_unix := opts.EndTime CountDate := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 1, 0, 0, currentTimeNow.Location()) + DataDate := currentTimeNow.Format("2006-01-02 15:04") CodeMergeCountMap := queryPullRequest(start_unix, end_unix) CommitCountMap := queryCommitAction(start_unix, end_unix, 5) @@ -472,7 +473,7 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi dateRecord.ID = userRecord.ID log.Info("i=" + fmt.Sprint(i) + " userName=" + userRecord.Name) dateRecord.CountDate = CountDate.Unix() - + dateRecord.DataDate = DataDate dateRecord.Email = userRecord.Email dateRecord.RegistDate = userRecord.CreatedUnix dateRecord.Name = userRecord.Name From 4af9b1d1f0e924f4e63569b922513eb0e7c35ac0 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 16:55:12 +0800 Subject: [PATCH 27/96] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index dd50cb964..0775ac899 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -1789,7 +1789,7 @@ func queryImageStars(start_unix int64, end_unix int64) (map[int64]int, map[int64 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)) + sess.Select("id,uid,image_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))) From 4f999089e02c91e5c38f70bb2bc1776f749c9327 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 17:18:04 +0800 Subject: [PATCH 28/96] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=95=8C=E9=9D=A2=E4=B8=8A=E4=B8=8A?= =?UTF-8?q?=E5=91=A8=E6=A6=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- web_src/js/components/UserAnalysis.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 587784712..cfc91d449 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -6,6 +6,7 @@
统计周期: + From 961797d915565d895779733d734d6277cef0f8a8 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 17:21:07 +0800 Subject: [PATCH 29/96] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=95=8C=E9=9D=A2=E4=B8=8A=E4=B8=8A?= =?UTF-8?q?=E5=91=A8=E6=A6=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/api/v1/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 03f13b195..9a05aa8ae 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -564,7 +564,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/query_user_static_page", operationReq, repo_ext.QueryUserStaticDataPage) m.Get("/query_user_current_month", operationReq, repo_ext.QueryUserStaticCurrentMonth) m.Get("/query_user_current_week", operationReq, repo_ext.QueryUserStaticCurrentWeek) - m.Get("/query_user_last_week", operationReq, repo_ext.QueryUserStaticCurrentWeek) + m.Get("/query_user_last_week", operationReq, repo_ext.QueryUserStaticLastWeek) m.Get("/query_user_current_year", operationReq, repo_ext.QueryUserStaticCurrentYear) m.Get("/query_user_last30_day", operationReq, repo_ext.QueryUserStaticLast30Day) m.Get("/query_user_last_month", operationReq, repo_ext.QueryUserStaticLastMonth) From 4527452232560686714999ab9f12526cb78610b0 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 17:26:32 +0800 Subject: [PATCH 30/96] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=95=8C=E9=9D=A2=E4=B8=8A=E4=B8=8A?= =?UTF-8?q?=E5=91=A8=E6=A6=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 0775ac899..a8520c10f 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -1030,7 +1030,12 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, if !userRecord.IsActive { continue } - statictisSess.Delete(&dateRecord) + + var deleteDateRecord UserBusinessAnalysis + deleteDateRecord.ID = userRecord.ID + deleteDateRecord.CountDate = CountDate.Unix() + statictisSess.Delete(&deleteDateRecord) + _, err = statictisSess.Insert(&dateRecord) if err != nil { log.Info("insert daterecord failed." + err.Error()) From 6180a1ee639f139f61a708729dac423f7519edea Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 17:47:43 +0800 Subject: [PATCH 31/96] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3=E6=97=B6=E9=97=B4=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 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index a8520c10f..b45ffa104 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -663,10 +663,8 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS log.Info("truncate all data from table: " + tableName) statictisSess.Exec("TRUNCATE TABLE " + tableName) - 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")) + log.Info("pageStartTime:" + pageStartTime.Format("2006-01-02 15:04:05")) + log.Info("pageEndTime time:" + pageEndTime.Format("2006-01-02 15:04:05")) start_unix := pageStartTime.Unix() end_unix := pageEndTime.Unix() @@ -682,7 +680,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS FocusRepoCountMap := queryWatch(start_unix, end_unix) StarRepoCountMap := queryStar(start_unix, end_unix) WatchedCountMap, WatchOtherMap := queryFollow(start_unix, end_unix) - CommitCodeSizeMap, err := GetAllUserKPIStats(StartTimeNextDay, EndTimeNextDay) + CommitCodeSizeMap, err := GetAllUserKPIStats(pageStartTime, pageEndTime) if err != nil { log.Info("query commit code errr.") } else { From d81e34bee04bf12549bab3bd8fff585c5a40abbe Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 17:50:11 +0800 Subject: [PATCH 32/96] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3=E6=97=B6=E9=97=B4=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 | 1 + 1 file changed, 1 insertion(+) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index b45ffa104..bef23e109 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -768,6 +768,7 @@ func refreshUserStaticTable(wikiCountMap map[string]int, tableName string, pageS dateRecordAll.NpuTrainJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuTrainJob", CloudBrainTaskItemMap) dateRecordAll.NpuInferenceJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_NpuInferenceJob", CloudBrainTaskItemMap) dateRecordAll.GpuBenchMarkJob = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_GpuBenchMarkJob", CloudBrainTaskItemMap) + dateRecordAll.CloudBrainRunTime = getMapKeyStringValue(fmt.Sprint(dateRecordAll.ID)+"_CloudBrainRunTime", CloudBrainTaskItemMap) dateRecordAll.CommitModelCount = getMapValue(dateRecordAll.ID, AiModelManageMap) dateRecordAll.CollectDataset = getMapValue(dateRecordAll.ID, CollectDataset) dateRecordAll.CollectedDataset = getMapValue(dateRecordAll.ID, CollectedDataset) From 5fb53c89e4754effe6935b08964357b683aa0d24 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 23 May 2022 18:51:52 +0800 Subject: [PATCH 33/96] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3=E6=97=B6=E9=97=B4=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 | 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 f631591d1..5ab7e286a 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -414,9 +414,7 @@ func DownloadUserDefineFile(ctx *context.Context) { log.Info("file not exist.") ctx.JSON(http.StatusOK, "File Not Exist.") } else { - ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+filename) - ctx.Resp.Header().Set("Content-Type", "application/octet-stream") - ctx.ServeFile(allFilename, filename) + ctx.ServeFile(allFilename, url.QueryEscape(filename)) } } From f5cd6cf70aa0e913271a7e4a8e46b67757460cb0 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 24 May 2022 09:41:56 +0800 Subject: [PATCH 34/96] fix-2142 --- routers/repo/cloudbrain.go | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 12d254812..efaefb6be 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -283,30 +283,6 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { mkModelPath(modelPath) uploadCodeToMinio(modelPath, jobName, cloudbrain.ModelMountPath+"/") - benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath - if setting.IsBenchmarkEnabled && jobType == string(models.JobTypeBenchmark) { - var gpuType string - for _, gpuInfo := range gpuInfos.GpuInfo { - if gpuInfo.Queue == gpuQueue { - gpuType = gpuInfo.Value - } - } - downloadRateCode(repo, jobName, setting.BenchmarkOwner, setting.BenchmarkName, benchmarkPath, form.BenchmarkCategory, gpuType) - uploadCodeToMinio(benchmarkPath+"/", jobName, cloudbrain.BenchMarkMountPath+"/") - } - - snn4imagenetPath := setting.JobPath + jobName + cloudbrain.Snn4imagenetMountPath - if setting.IsSnn4imagenetEnabled && jobType == string(models.JobTypeSnn4imagenet) { - downloadRateCode(repo, jobName, setting.Snn4imagenetOwner, setting.Snn4imagenetName, snn4imagenetPath, "", "") - uploadCodeToMinio(snn4imagenetPath+"/", jobName, cloudbrain.Snn4imagenetMountPath+"/") - } - - brainScorePath := setting.JobPath + jobName + cloudbrain.BrainScoreMountPath - if setting.IsBrainScoreEnabled && jobType == string(models.JobTypeBrainScore) { - downloadRateCode(repo, jobName, setting.BrainScoreOwner, setting.BrainScoreName, brainScorePath, "", "") - uploadCodeToMinio(brainScorePath+"/", jobName, cloudbrain.BrainScoreMountPath+"/") - } - err = cloudbrain.GenerateTask(ctx, displayJobName, jobName, image, command, uuid, storage.GetMinioPath(jobName, cloudbrain.CodeMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.ModelMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), @@ -1241,7 +1217,7 @@ func downloadCode(repo *models.Repository, codePath, branchName string) error { return nil } -func downloadRateCode(repo *models.Repository, taskName, rateOwnerName, rateRepoName, codePath, benchmarkCategory, gpuType string) error { +func downloadRateCode(repo *models.Repository, taskName, rateOwnerName, rateRepoName, codePath, benchmarkCategory, gpuType, userName string) error { err := os.MkdirAll(codePath, os.ModePerm) if err != nil { log.Error("mkdir codePath failed", err.Error()) @@ -1269,7 +1245,7 @@ func downloadRateCode(repo *models.Repository, taskName, rateOwnerName, rateRepo defer f.Close() data, err := json.Marshal(models.TaskInfo{ - Username: repo.Owner.Name, + Username: userName, TaskName: taskName, CodeName: repo.Name, BenchmarkCategory: strings.Split(benchmarkCategory, ","), @@ -1970,7 +1946,7 @@ func BenchMarkAlgorithmCreate(ctx *context.Context, form auth.CreateCloudBrainFo } } - if err := downloadRateCode(repo, jobName, childInfo.Owner, childInfo.RepoName, benchmarkPath, form.BenchmarkCategory, gpuType); err != nil { + if err := downloadRateCode(repo, jobName, childInfo.Owner, childInfo.RepoName, benchmarkPath, form.BenchmarkCategory, gpuType, ctx.User.Name); err != nil { log.Error("downloadRateCode failed, %v", err, ctx.Data["MsgID"]) //cloudBrainNewDataPrepare(ctx) //ctx.RenderWithErr("system error", tplCloudBrainBenchmarkNew, &form) @@ -2068,7 +2044,7 @@ func ModelBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainForm) snn4imagenetPath := setting.JobPath + jobName + cloudbrain.Snn4imagenetMountPath if setting.IsSnn4imagenetEnabled && jobType == string(models.JobTypeSnn4imagenet) { - downloadRateCode(repo, jobName, setting.Snn4imagenetOwner, setting.Snn4imagenetName, snn4imagenetPath, "", "") + downloadRateCode(repo, jobName, setting.Snn4imagenetOwner, setting.Snn4imagenetName, snn4imagenetPath, "", "", ctx.User.Name) uploadCodeToMinio(snn4imagenetPath+"/", jobName, cloudbrain.Snn4imagenetMountPath+"/") command = fmt.Sprintf(cloudbrain.Snn4imagenetCommand, displayJobName, trimSpaceNewlineInString(form.Description)) @@ -2076,7 +2052,7 @@ func ModelBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainForm) benchmarkChildTypeID := 0 brainScorePath := setting.JobPath + jobName + cloudbrain.BrainScoreMountPath if setting.IsBrainScoreEnabled && jobType == string(models.JobTypeBrainScore) { - downloadRateCode(repo, jobName, setting.BrainScoreOwner, setting.BrainScoreName, brainScorePath, "", "") + downloadRateCode(repo, jobName, setting.BrainScoreOwner, setting.BrainScoreName, brainScorePath, "", "", ctx.User.Name) uploadCodeToMinio(brainScorePath+"/", jobName, cloudbrain.BrainScoreMountPath+"/") benchmarkChildTypeID = form.BenchmarkChildTypeID command = fmt.Sprintf(cloudbrain.BrainScoreCommand, getBrainRegion(benchmarkChildTypeID), displayJobName, trimSpaceNewlineInString(form.Description)) From 531a1c72f9c5418c23b9c8c529a6f974835529c9 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 24 May 2022 11:08:14 +0800 Subject: [PATCH 35/96] =?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 | 15 +-------------- routers/repo/user_data_analysis.go | 3 +-- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index bef23e109..8919efcf0 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -534,7 +534,7 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi break } } - log.Info("query user define,count=" + fmt.Sprint((ResultList))) + log.Info("query user define,count=" + fmt.Sprint(len(ResultList))) return ResultList, int64(len(ResultList)) } @@ -1026,20 +1026,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, log.Info("has activity." + userRecord.Name) addUserToMap(userNewAddActivity, userRecord.CreatedUnix, dateRecord.ID) } - if !userRecord.IsActive { - continue - } - var deleteDateRecord UserBusinessAnalysis - deleteDateRecord.ID = userRecord.ID - deleteDateRecord.CountDate = CountDate.Unix() - statictisSess.Delete(&deleteDateRecord) - - _, err = statictisSess.Insert(&dateRecord) - if err != nil { - log.Info("insert daterecord failed." + err.Error()) - return err - } } indexTotal += PAGE_SIZE diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 5ab7e286a..a43b91df8 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -542,14 +542,13 @@ func QueryUserStaticDataPage(ctx *context.Context) { endTime = time.Now() } else { startTime, _ = time.ParseInLocation("2006-01-02", startDate, time.Local) - startTime = time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 12, 0, 0, 0, startTime.Location()) + startTime = time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 0, 0, 0, 0, startTime.Location()) settingStartTime, _ := time.Parse("2006-01-02", setting.RadarMap.RecordBeginTime) if startTime.Unix() < settingStartTime.Unix() { startTime = settingStartTime startDate = settingStartTime.Format("2006-01-02") } endTime, _ = time.ParseInLocation("2006-01-02", endDate, time.Local) - //endTime = endTime.AddDate(0, 0, 1) endTime = time.Date(endTime.Year(), endTime.Month(), endTime.Day(), 23, 59, 59, 0, startTime.Location()) isAll = false From 27630014b9eb586a172f05936e2594950613d8a6 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 24 May 2022 16:37:15 +0800 Subject: [PATCH 36/96] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=94=B9=E7=89=88?= =?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 --- public/home/home.js | 89 ++++++++++++++++++++++++++++++++---------------- routers/home.go | 79 +++++++++++++++++++++++++++++------------- routers/routes/routes.go | 7 ++-- templates/home.tmpl | 6 ++-- 4 files changed, 122 insertions(+), 59 deletions(-) diff --git a/public/home/home.js b/public/home/home.js index 1f11b9a4f..9a4847e73 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -117,6 +117,7 @@ socket.onmessage = function (e) { continue; } } + refresh3DInfo(record); var recordPrefix = getMsg(record); if(record.OpType == "6" || record.OpType == "10" || record.OpType == "12" || record.OpType == "13"){ html += recordPrefix + actionName; @@ -200,6 +201,22 @@ function getTaskLink(record){ return re; } +function refresh3DInfo(record){ + if(record.OpType == "25" || record.OpType == "29" || record.OpType == "31"){ + //cloudbrain one + var lines = $('.rotation3D__line blue'); + console.log("cloudbrain one line length=" + lines.length); + lines[0].find("span").text(record.RefName); + + }else if(record.OpType == "26" || record.OpType == "27" || record.OpType == "28"){ + //cloudbrain two + var lines = $('.rotation3D__line blue'); + console.log("cloudbrain two line length=" + lines.length); + lines[1].find("span").text(record.RefName); + } + +} + function getMsg(record){ var html =""; html += "
"; @@ -418,48 +435,60 @@ queryRecommendData(); function queryRecommendData(){ $.ajax({ type:"GET", - url:"/recommend/org", + url:"/recommend/home", headers: { authorization:token, }, dataType:"json", async:false, success:function(json){ - displayOrg(json); + displayOrg(json.org); + displayRepo(json.repo); + displayActivity(json.image); + displayCloudBrain(json.cloudbrain) }, error:function(response) { } }); - $.ajax({ - type:"GET", - url:"/recommend/repo", - headers: { - authorization:token, - }, - dataType:"json", - async:false, - success:function(json){ - displayRepo(json); - }, - error:function(response) { - } - }); + // $.ajax({ + // type:"GET", + // url:"/recommend/repo", + // headers: { + // authorization:token, + // }, + // dataType:"json", + // async:false, + // success:function(json){ + // displayRepo(json); + // }, + // error:function(response) { + // } + // }); + + // $.ajax({ + // type:"GET", + // url:"/recommend/imageinfo", + // headers: { + // authorization:token, + // }, + // dataType:"json", + // async:false, + // success:function(json){ + // displayActivity(json); + // }, + // error:function(response) { + // } + // }); +} - $.ajax({ - type:"GET", - url:"/recommend/imageinfo", - headers: { - authorization:token, - }, - dataType:"json", - async:false, - success:function(json){ - displayActivity(json); - }, - error:function(response) { - } - }); +function displayCloudBrain(json){ + var completed_task = document.getElementById("completed_task"); + completed_task.text(json.completed_task); + var running_task = document.getElementById("running_task"); + running_task.text(json.running_task); + var wait_task = document.getElementById("wait_task"); + wait_task.text(json.wait_task); } function displayActivity(json){ diff --git a/routers/home.go b/routers/home.go index e37cacb01..09fe97dc6 100755 --- a/routers/home.go +++ b/routers/home.go @@ -471,7 +471,7 @@ func ExploreOrganizations(ctx *context.Context) { return } - recommendOrgs, err := GetRecommendOrg() + recommendOrgs, err := getRecommendOrg() if err != nil { log.Error("GetRecommendOrgInfos failed:%v", err.Error(), ctx.Data["MsgID"]) ctx.ServerError("GetRecommendOrgInfos", err) @@ -606,31 +606,31 @@ func ExploreImages(ctx *context.Context) { } func ExploreDataAnalysisUserTrend(ctx *context.Context) { - ctx.Data["url_params"]="UserTrend" + ctx.Data["url_params"] = "UserTrend" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysisUserAnalysis(ctx *context.Context) { - ctx.Data["url_params"]="UserAnalysis" + ctx.Data["url_params"] = "UserAnalysis" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysisProTrend(ctx *context.Context) { - ctx.Data["url_params"]="ProTrend" + ctx.Data["url_params"] = "ProTrend" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysisProAnalysis(ctx *context.Context) { - ctx.Data["url_params"]="ProAnalysis" + ctx.Data["url_params"] = "ProAnalysis" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysisOverview(ctx *context.Context) { - ctx.Data["url_params"]="Overview" + ctx.Data["url_params"] = "Overview" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysisBrainAnalysis(ctx *context.Context) { - ctx.Data["url_params"]="BrainAnalysis" + ctx.Data["url_params"] = "BrainAnalysis" ctx.HTML(200, tplExploreExploreDataAnalysis) } func ExploreDataAnalysis(ctx *context.Context) { - ctx.Data["url_params"]="" + ctx.Data["url_params"] = "" ctx.HTML(200, tplExploreExploreDataAnalysis) } @@ -640,7 +640,7 @@ func NotFound(ctx *context.Context) { ctx.NotFound("home.NotFound", nil) } -func GetRecommendOrg() ([]map[string]interface{}, error) { +func getRecommendOrg() ([]map[string]interface{}, error) { url := setting.RecommentRepoAddr + "organizations" result, err := repository.RecommendFromPromote(url) @@ -668,7 +668,7 @@ func GetRecommendOrg() ([]map[string]interface{}, error) { } return resultOrg, nil } -func GetImageInfo() ([]map[string]interface{}, error) { +func getImageInfo() ([]map[string]interface{}, error) { url := setting.RecommentRepoAddr + "picture_info" result, err := repository.RecommendFromPromote(url) @@ -731,14 +731,14 @@ func GetRankUser(index string) ([]map[string]interface{}, error) { return resultOrg, nil } -func GetImageInfoFromPromote(ctx *context.Context) { - imageInfo, err := GetImageInfo() - if err != nil { - ctx.ServerError("500", err) - return - } - ctx.JSON(200, imageInfo) -} +// func GetImageInfoFromPromote(ctx *context.Context) { +// imageInfo, err := GetImageInfo() +// if err != nil { +// ctx.ServerError("500", err) +// return +// } +// ctx.JSON(200, imageInfo) +// } func GetUserRankFromPromote(ctx *context.Context) { index := ctx.Params("index") @@ -750,15 +750,48 @@ func GetUserRankFromPromote(ctx *context.Context) { ctx.JSON(200, resultUserRank) } -func RecommendOrgFromPromote(ctx *context.Context) { - resultOrg, err := GetRecommendOrg() +func RecommendHomeInfo(ctx *context.Context) { + resultOrg, err := getRecommendOrg() if err != nil { - ctx.ServerError("500", err) - return + log.Info("error." + err.Error()) } - ctx.JSON(200, resultOrg) + resultRepo, err := repository.GetRecommendRepoFromPromote("projects") + if err != nil { + log.Info("error." + err.Error()) + } + resultImage, err := getImageInfo() + if err != nil { + log.Info("error." + err.Error()) + } + resultCloudBrain, err := getCloudbrainNums() + if err != nil { + log.Info("error." + err.Error()) + } + mapInterface := make(map[string]interface{}) + mapInterface["org"] = resultOrg + mapInterface["repo"] = resultRepo + mapInterface["image"] = resultImage + mapInterface["cloudbrain"] = resultCloudBrain + ctx.JSON(http.StatusOK, mapInterface) } +func getCloudbrainNums() (map[string]string, error) { + result := make(map[string]string) + result["completed_task"] = "1800" + result["running_task"] = "20" + result["wait_task"] = "30" + return result, nil +} + +// func RecommendOrgFromPromote(ctx *context.Context) { +// resultOrg, err := GetRecommendOrg() +// if err != nil { +// ctx.ServerError("500", err) +// return +// } +// ctx.JSON(200, resultOrg) +// } + func RecommendRepoFromPromote(ctx *context.Context) { result, err := repository.GetRecommendRepoFromPromote("projects") if err != nil { diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 4c3f5f472..12d0e1cf8 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -323,10 +323,11 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/dashboard", routers.Dashboard) go routers.SocketManager.Run() m.Get("/action/notification", routers.ActionNotification) - m.Get("/recommend/org", routers.RecommendOrgFromPromote) - m.Get("/recommend/repo", routers.RecommendRepoFromPromote) + m.Get("/recommend/home", routers.RecommendHomeInfo) + //m.Get("/recommend/org", routers.RecommendOrgFromPromote) + //m.Get("/recommend/repo", routers.RecommendRepoFromPromote) m.Get("/recommend/userrank/:index", routers.GetUserRankFromPromote) - m.Get("/recommend/imageinfo", routers.GetImageInfoFromPromote) + //m.Get("/recommend/imageinfo", routers.GetImageInfoFromPromote) m.Post("/all/search/", routers.Search) m.Get("/all/search/", routers.EmptySearch) m.Get("/all/dosearch/", routers.SearchApi) diff --git a/templates/home.tmpl b/templates/home.tmpl index aa7a21ccc..ccf734081 100755 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -4,9 +4,9 @@
-

完成AI任务
1716

-

运行AI任务
120

-

等待AI任务
80

+

完成AI任务
1716

+

运行AI任务
120

+

等待AI任务
80

From 616d002d2f69971ae3f0c721c9d5b67fd412a38a Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 24 May 2022 16:47:40 +0800 Subject: [PATCH 37/96] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=94=B9=E7=89=88?= =?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 --- public/home/home.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/public/home/home.js b/public/home/home.js index 9a4847e73..89aad85e0 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -483,12 +483,9 @@ function queryRecommendData(){ } function displayCloudBrain(json){ - var completed_task = document.getElementById("completed_task"); - completed_task.text(json.completed_task); - var running_task = document.getElementById("running_task"); - running_task.text(json.running_task); - var wait_task = document.getElementById("wait_task"); - wait_task.text(json.wait_task); + $('#completed_task').text(json.completed_task); + $('#running_task').text(json.running_task); + $('#wait_task').text(json.wait_task); } function displayActivity(json){ From 656b5e89c73292e2746aecfe1920dfebacca52d3 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 24 May 2022 16:51:20 +0800 Subject: [PATCH 38/96] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=94=B9=E7=89=88?= =?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 --- public/home/home.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/home/home.js b/public/home/home.js index 89aad85e0..bf0da85d6 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -204,13 +204,13 @@ function getTaskLink(record){ function refresh3DInfo(record){ if(record.OpType == "25" || record.OpType == "29" || record.OpType == "31"){ //cloudbrain one - var lines = $('.rotation3D__line blue'); + var lines = $('.rotation3D__line'); console.log("cloudbrain one line length=" + lines.length); lines[0].find("span").text(record.RefName); }else if(record.OpType == "26" || record.OpType == "27" || record.OpType == "28"){ //cloudbrain two - var lines = $('.rotation3D__line blue'); + var lines = $('.rotation3D__line'); console.log("cloudbrain two line length=" + lines.length); lines[1].find("span").text(record.RefName); } From c50ee706b3e982b7a716753e6925687e9fe0ed2e Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 24 May 2022 16:55:49 +0800 Subject: [PATCH 39/96] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=94=B9=E7=89=88?= =?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 --- public/home/home.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/home/home.js b/public/home/home.js index bf0da85d6..2d27c76f5 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -205,14 +205,15 @@ function refresh3DInfo(record){ if(record.OpType == "25" || record.OpType == "29" || record.OpType == "31"){ //cloudbrain one var lines = $('.rotation3D__line'); - console.log("cloudbrain one line length=" + lines.length); + var spans = $('.rotation3D__line').find("span") + console.log("cloudbrain one line length=" + lines.length + " spans=" + spans.length); lines[0].find("span").text(record.RefName); }else if(record.OpType == "26" || record.OpType == "27" || record.OpType == "28"){ //cloudbrain two var lines = $('.rotation3D__line'); console.log("cloudbrain two line length=" + lines.length); - lines[1].find("span").text(record.RefName); + //lines[1].find("span").text(record.RefName); } } From 4330c46658792218327cab63138878fc02870770 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 24 May 2022 16:58:05 +0800 Subject: [PATCH 40/96] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=94=B9=E7=89=88?= =?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 --- public/home/home.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/home/home.js b/public/home/home.js index 2d27c76f5..bca9ddb1e 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -205,14 +205,14 @@ function refresh3DInfo(record){ if(record.OpType == "25" || record.OpType == "29" || record.OpType == "31"){ //cloudbrain one var lines = $('.rotation3D__line'); - var spans = $('.rotation3D__line').find("span") - console.log("cloudbrain one line length=" + lines.length + " spans=" + spans.length); - lines[0].find("span").text(record.RefName); - + $('.rotation3D__line').find("span").eq(0).text(record.RefName) + console.log("cloudbrain one line length=" + lines.length); + //lines[0].find("span").text(record.RefName); }else if(record.OpType == "26" || record.OpType == "27" || record.OpType == "28"){ //cloudbrain two var lines = $('.rotation3D__line'); console.log("cloudbrain two line length=" + lines.length); + $('.rotation3D__line').find("span").eq(1).text(record.RefName) //lines[1].find("span").text(record.RefName); } From 6216bcc30772b1d1be183ab985cbb27f29c02f56 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 24 May 2022 17:03:29 +0800 Subject: [PATCH 41/96] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=94=B9=E7=89=88?= =?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 --- public/home/home.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/home/home.js b/public/home/home.js index bca9ddb1e..6bba5134a 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -205,14 +205,16 @@ function refresh3DInfo(record){ if(record.OpType == "25" || record.OpType == "29" || record.OpType == "31"){ //cloudbrain one var lines = $('.rotation3D__line'); - $('.rotation3D__line').find("span").eq(0).text(record.RefName) + var span = $('.rotation3D__line').find("span")[0]; + console.log(span); + //$('.rotation3D__line').find("span").eq(0).text(record.RefName) console.log("cloudbrain one line length=" + lines.length); //lines[0].find("span").text(record.RefName); }else if(record.OpType == "26" || record.OpType == "27" || record.OpType == "28"){ //cloudbrain two var lines = $('.rotation3D__line'); console.log("cloudbrain two line length=" + lines.length); - $('.rotation3D__line').find("span").eq(1).text(record.RefName) + //$('.rotation3D__line').find("span").eq(1).text(record.RefName) //lines[1].find("span").text(record.RefName); } From 460bff4614bde11e9acda192c2f9a98d2472dca5 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 24 May 2022 17:07:32 +0800 Subject: [PATCH 42/96] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=94=B9=E7=89=88?= =?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 --- public/home/home.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/home/home.js b/public/home/home.js index 6bba5134a..33c7edc47 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -207,6 +207,7 @@ function refresh3DInfo(record){ var lines = $('.rotation3D__line'); var span = $('.rotation3D__line').find("span")[0]; console.log(span); + span.innerText =record.RefName; //$('.rotation3D__line').find("span").eq(0).text(record.RefName) console.log("cloudbrain one line length=" + lines.length); //lines[0].find("span").text(record.RefName); @@ -214,6 +215,9 @@ function refresh3DInfo(record){ //cloudbrain two var lines = $('.rotation3D__line'); console.log("cloudbrain two line length=" + lines.length); + var span = $('.rotation3D__line').find("span")[1]; + console.log(span); + span.innerText =record.RefName; //$('.rotation3D__line').find("span").eq(1).text(record.RefName) //lines[1].find("span").text(record.RefName); } From 48076aabd743e876ad91446bf162767d4cdc31cc Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 24 May 2022 17:29:19 +0800 Subject: [PATCH 43/96] fix issue --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + templates/repo/attachment/upload.tmpl | 101 +++++++++++++++++----------------- templates/repo/datasets/index.tmpl | 35 ++++++++++-- web_src/js/index.js | 37 ++++++++----- web_src/less/openi.less | 30 ++++++++++ 6 files changed, 136 insertions(+), 69 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index ef3ad7705..531da38d3 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2945,6 +2945,7 @@ raw_minutes = minutes [dropzone] default_message = Drop files or click here to upload. +default_dataset_message = Click to add files or directly drag and drop files here invalid_input_type = You can not upload files of this type. file_too_big = File size ({{filesize}} MB) exceeds the maximum size of ({{maxFilesize}} MB). remove_file = Remove file diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 2f0bbe91d..536584d53 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2955,6 +2955,7 @@ raw_minutes=分钟 [dropzone] default_message=拖动文件或者点击此处上传。 +default_dataset_message=点击添加文件或直接拖拽文件到此处。 invalid_input_type=您不能上传该类型的文件 file_too_big=文件体积({{filesize}} MB)超过了最大允许体积({{maxFilesize}} MB) remove_file=移除文件 diff --git a/templates/repo/attachment/upload.tmpl b/templates/repo/attachment/upload.tmpl index 56dc52417..a78931b13 100644 --- a/templates/repo/attachment/upload.tmpl +++ b/templates/repo/attachment/upload.tmpl @@ -1,60 +1,58 @@ - {{template "base/head" .}}
-{{template "repo/header" .}} + {{template "repo/header" .}}
-

- {{$.i18n.Tr "dataset.upload_dataset_file"}} -

-
-
- - {{.CsrfTokenHtml}} - - CPU/GPU - NPU - - - - - +

+ {{$.i18n.Tr "dataset.upload_dataset_file"}} +

+
+
+ + {{.CsrfTokenHtml}} + + + CPU/GPU + NPU + + + + + + - - -
+ +
+

{{$.i18n.Tr "dataset.illustrate"}}:

-

{{$.i18n.Tr "dataset.illustrate.only"}} {{$.i18n.Tr "dataset.illustrate.zip"}} {{$.i18n.Tr "dataset.illustrate.fisrt_end"}};
+

{{$.i18n.Tr "dataset.illustrate.only"}} {{$.i18n.Tr "dataset.illustrate.zip"}} {{$.i18n.Tr "dataset.illustrate.fisrt_end"}};
{{$.i18n.Tr "dataset.dataset_explain"}}

-{{template "base/footer" .}} +{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index f9f6a10fc..378c5df23 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -7,6 +7,8 @@ background: #FFF !important; } + + .dataset_title { font-size: 14px; max-width: 80%; @@ -117,6 +119,15 @@ max-width: 400px; } +
+
+
+
+
+
+
+
+
{{template "repo/header" .}} {{if .dataset}} @@ -211,11 +222,22 @@
-
- {{$.i18n.Tr "dataset.dataset_file_name"}} +
+ {{$.i18n.Tr "dataset.dataset_file_name"}} + + + +
-
+
{{$.i18n.Tr "repo.model.manage.size"}} + + + +
{{$.i18n.Tr "dataset.dataset_available_clusters"}} @@ -226,8 +248,13 @@
{{$.i18n.Tr "repo.cloudbrain_creator"}}
-
+
{{$.i18n.Tr "dataset.dataset_upload_time"}} + + + +
{{$.i18n.Tr "repo.cloudbrain_operate"}} diff --git a/web_src/js/index.js b/web_src/js/index.js index f3f25c03a..b10e54a06 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1225,10 +1225,7 @@ async function initRepository() { const $content = $segment.parent(); if (!$content.find('.ui.small.images').length) { if (data.attachments !== '') { - $content.append( - '
' - ); - $content.find('.ui.small.images').html(data.attachments); + } } else if (data.attachments === '') { $content @@ -3923,19 +3920,10 @@ function initVueDataset() { MinioUploader }, mounted() { - // if(document.getElementById('postPath')){ - // this.url = document.getElementById('postPath').value - // } - // this.privates = items - // this.num_stars = num_stars - // this.star_active = star_active - // this.ruleForm1 = ruleForm - - // // this.getEditInit() - // this.getTypeList() this.getTypeList() if (!!document.getElementById('dataset-repolink-init')) { + this.cloudbrainType = location.href.indexOf('cloudbrain/train-job/create') !== -1 ? 0 : 1 this.getCurrentRepoDataset(this.repolink, this.cloudbrainType) } @@ -4083,6 +4071,27 @@ function initVueDataset() { uploadNpu() { this.type = 1 }, + sortAble(dom) { + const params = new URLSearchParams(location.search) + if (params.toString() === '') { + location.href = `${location.href}?sort=${dom}Asc` + } + else if (params.get('sort') === `${dom}Desc` || params.get('sort').indexOf(`${dom}`) === -1) { + if (params.get('page')) { + location.search = `?sort=${dom}Asc&page=${params.get('page')}` + } else { + location.search = `?sort=${dom}Asc` + } + } + else { + if (params.get('page')) { + location.search = `?sort=${dom}Desc&page=${params.get('page')}` + } else { + location.search = `?sort=${dom}Desc` + } + + } + }, setPrivate(uuid, privateFlag, index) { const params = { _csrf: csrf, file: uuid, is_private: privateFlag } this.$axios.post('/attachments/private', this.qs.stringify(params)).then((res) => { diff --git a/web_src/less/openi.less b/web_src/less/openi.less index de2a3fe8c..dc02d65bc 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -1055,3 +1055,33 @@ display: block; float: left !important; margin: 0px 5px 0px 0px !important; } + + +.row .caret-wrapper { + display: inline-flex; + flex-direction: column; + align-items: center; + height: 34px; + width: 24px; + vertical-align: middle; + cursor: pointer; + position: relative; + } + +.row .sort-caret-up { + position: absolute; + top: 5px; + color: #c0c4cc; + font-size: 18px; + } + +.row .sort-caret-down { + position: absolute; + bottom: 3px; + color: #c0c4cc; + font-size: 18px; + } + +.row .active-sort { + color: #409eff !important; + } \ No newline at end of file From 455334348ef9935f53eb200fc19dc4717a0b7247 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 24 May 2022 17:32:16 +0800 Subject: [PATCH 44/96] fix issue --- templates/repo/datasets/index.tmpl | 9 --------- 1 file changed, 9 deletions(-) diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index 378c5df23..4cc84bbe8 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -119,15 +119,6 @@ max-width: 400px; } -
-
-
-
-
-
-
-
-
{{template "repo/header" .}} {{if .dataset}} From 9efd1ceb15957b0cc86fe25166945e807a026483 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 24 May 2022 18:09:37 +0800 Subject: [PATCH 45/96] #2146 fix bug --- modules/repofiles/update.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go index d7751d50e..07440301a 100644 --- a/modules/repofiles/update.go +++ b/modules/repofiles/update.go @@ -783,6 +783,7 @@ func RenameRepoFile(repo *models.Repository, doer *models.User, opts *RenameRepo // Check that the path given in opts.treePath is valid (not a git path) treePath := CleanUploadFileName(opts.TreePath) + treePath = strings.ReplaceAll(treePath, " ", "") if treePath == "" { return models.ErrFilenameInvalid{ Path: opts.TreePath, @@ -942,16 +943,16 @@ func moveAndAddFiles(oldTreePath, newTreePath string, t *TemporaryUploadReposito } //example for v(mode SHA-1 stage file) //100755 d294c88235ac05d3dece028d8a65590f28ec46ac 0 custom/conf/app.ini - v = strings.ReplaceAll(v, "0\t", "") - tmpArray := strings.Split(v, " ") - oldPath := tmpArray[2] + tempArray := strings.Split(v, "0\t") + leftArray := strings.Split(tempArray[0], " ") + oldPath := tempArray[1] newPath := newTreePath + strings.TrimPrefix(oldPath, oldTreePath) // mode 0 means remove file stdIn.WriteString("0 0000000000000000000000000000000000000000\t") stdIn.WriteString(oldPath) stdIn.WriteByte('\000') - stdIn.WriteString(tmpArray[0] + " ") - stdIn.WriteString(tmpArray[1] + "\t") + stdIn.WriteString(leftArray[0] + " ") + stdIn.WriteString(leftArray[1] + "\t") stdIn.WriteString(newPath) stdIn.WriteByte('\000') } From 80e95267d26cbed0f099411a08955a56787b8d1d Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 24 May 2022 18:34:59 +0800 Subject: [PATCH 46/96] fix issue --- web_src/js/index.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/web_src/js/index.js b/web_src/js/index.js index b10e54a06..b7434885e 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -4076,20 +4076,18 @@ function initVueDataset() { if (params.toString() === '') { location.href = `${location.href}?sort=${dom}Asc` } + else if (!params.get('sort')) { + location.href = `${location.href}&sort=${dom}Asc` + } else if (params.get('sort') === `${dom}Desc` || params.get('sort').indexOf(`${dom}`) === -1) { - if (params.get('page')) { - location.search = `?sort=${dom}Asc&page=${params.get('page')}` - } else { - location.search = `?sort=${dom}Asc` - } + params.delete('sort') + let asc = params.toString() + `&sort=${dom}Asc` + location.search = asc } else { - if (params.get('page')) { - location.search = `?sort=${dom}Desc&page=${params.get('page')}` - } else { - location.search = `?sort=${dom}Desc` - } - + params.delete('sort') + let desc = params.toString() + `&sort=${dom}Desc` + location.search = desc } }, setPrivate(uuid, privateFlag, index) { From 29f27968e048404f81ecf5d6e74adad48b27095c Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 25 May 2022 16:21:38 +0800 Subject: [PATCH 47/96] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_en-US.ini | 3 +++ options/locale/locale_zh-CN.ini | 3 +++ routers/repo/user_data_analysis.go | 22 ++++++++++++++++++++++ web_src/js/components/UserAnalysis.vue | 14 +++++++++++++- web_src/js/components/UserTrend.vue | 11 ++++++++--- 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 265e7ed36..7b7f22bce 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -519,6 +519,8 @@ static.RecommendDataset=Recommended Dataset Count static.CollectImage=Collect Image Count static.CollectedImage=Collected Image Count static.RecommendImage=Recommended Image Count +static.email=Email +static.location=Location static.all=All static.public.user_business_analysis_current_month=Current_Month static.public.user_business_analysis_current_week=Current_Week @@ -537,6 +539,7 @@ metrics.hasactivateuser=New contributing activities metrics.newregistnotactiveuser=New inactive metrics.averageuser=Average new users metrics.newuseractiveindex=Activation rate of new users +metrics.currentdayactivity=Current day contributing activities metrics.totalregistuser=Cumulative registered users metrics.totalactiveduser=Cumulative activated users metrics.totalhasactivityuser=Cumulative active users diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 1b26a930c..cc3b5ddd9 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -524,6 +524,8 @@ static.RecommendDataset=被推荐数据集数 static.CollectImage=收藏镜像数 static.CollectedImage=被收藏镜像数 static.RecommendImage=被推荐镜像数 +static.email=Email +static.location=所在地区 static.all=所有 static.public.user_business_analysis_current_month=本月 static.public.user_business_analysis_current_week=本周 @@ -542,6 +544,7 @@ metrics.hasactivateuser=新增有贡献活动 metrics.newregistnotactiveuser=新增未激活 metrics.averageuser=平均新增用户 metrics.newuseractiveindex=新增用户激活率 +metrics.currentdayactivity=当日有贡献活动 metrics.totalregistuser=累计注册用户 metrics.totalactiveduser=累计已激活 metrics.totalhasactivityuser=累计有贡献活动 diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index a43b91df8..b14170efb 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -29,6 +29,7 @@ func getUserMetricsExcelHeader(ctx *context.Context) map[string]string { excelHeader = append(excelHeader, ctx.Tr("user.metrics.hasactivateuser")) excelHeader = append(excelHeader, ctx.Tr("user.metrics.newregistnotactiveuser")) excelHeader = append(excelHeader, ctx.Tr("user.metrics.newuseractiveindex")) + excelHeader = append(excelHeader, ctx.Tr("user.metrics.currentdayactivity")) excelHeader = append(excelHeader, ctx.Tr("user.metrics.totalregistuser")) excelHeader = append(excelHeader, ctx.Tr("user.metrics.totalactiveduser")) excelHeader = append(excelHeader, ctx.Tr("user.metrics.totalhasactivityuser")) @@ -67,6 +68,10 @@ func writeUserMetricsExcel(row int, xlsx *excelize.File, sheetName string, userM } xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, value) tmp = tmp + 1 + + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userMetrics.HasActivityUser) + tmp = tmp + 1 + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userMetrics.TotalUser) tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userMetrics.TotalActivateRegistUser) @@ -106,6 +111,9 @@ func getExcelHeader(ctx *context.Context) map[string]string { excelHeader = append(excelHeader, ctx.Tr("user.static.CollectedImage")) excelHeader = append(excelHeader, ctx.Tr("user.static.RecommendImage")) + excelHeader = append(excelHeader, ctx.Tr("user.static.email")) + excelHeader = append(excelHeader, ctx.Tr("user.static.RecommendImage")) + excelHeader = append(excelHeader, ctx.Tr("user.static.registdate")) excelHeader = append(excelHeader, ctx.Tr("user.static.countdate")) @@ -181,6 +189,13 @@ func writeExcel(row int, xlsx *excelize.File, sheetName string, userRecord *mode tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.RecommendImage) tmp = tmp + 1 + + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Email) + tmp = tmp + 1 + + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.UserLocation) + 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 @@ -249,6 +264,13 @@ func writeExcelPage(row int, xlsx *excelize.File, sheetName string, userRecord * tmp = tmp + 1 xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.RecommendImage) tmp = tmp + 1 + + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.Email) + tmp = tmp + 1 + + xlsx.SetCellValue(sheetName, getColumn(tmp)+rows, userRecord.UserLocation) + 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 diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index cfc91d449..79a593137 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -214,6 +214,18 @@ width="120px" align="center"> + + + + 昨日新增注册用户数 未激活:{{ tableDataYesterday.NotActivateRegistUser }} 已激活: {{ tableDataYesterday.ActivateRegistUser }} - 有贡献活动: {{ tableDataYesterday.HasActivityUser }} + 有贡献活动: {{ tableDataYesterday.RegistActivityUser }} @@ -114,7 +114,7 @@ align="center"> @@ -131,6 +131,11 @@ {{scope.row.ActivateIndex | rounding}} + + Date: Wed, 25 May 2022 16:26:02 +0800 Subject: [PATCH 48/96] add jobstatus analysis --- models/cloudbrain_static.go | 30 +++++++++++++++ routers/api/v1/api.go | 3 ++ routers/api/v1/repo/cloudbrain_dashboard.go | 58 +++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 models/cloudbrain_static.go diff --git a/models/cloudbrain_static.go b/models/cloudbrain_static.go new file mode 100644 index 000000000..de3575632 --- /dev/null +++ b/models/cloudbrain_static.go @@ -0,0 +1,30 @@ +package models + +func GetJobWaitingCount() (int64, error) { + countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(JobWaiting) + "'" + return x.SQL(countSql).Count() +} +func GetJobStoppedCount() (int64, error) { + countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(JobStopped) + "'" + return x.SQL(countSql).Count() +} +func GetJobCompletedCount() (int64, error) { + countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(ModelArtsTrainJobCompleted) + "'" + return x.SQL(countSql).Count() +} +func GetJobFailedCount() (int64, error) { + countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(JobFailed) + "'" + return x.SQL(countSql).Count() +} +func GetJobRunningCount() (int64, error) { + countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(JobRunning) + "'" + return x.SQL(countSql).Count() +} +func GetJobKilledCount() (int64, error) { + countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(ModelArtsTrainJobKilled) + "'" + return x.SQL(countSql).Count() +} +func GetJobInitCount() (int64, error) { + countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(ModelArtsTrainJobInit) + "'" + return x.SQL(countSql).Count() +} diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 9a05aa8ae..17122b09d 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -573,6 +573,9 @@ func RegisterRoutes(m *macaron.Macaron) { //cloudbrain board m.Group("/cloudbrainboard", func() { m.Get("/downloadAll", repo.DownloadCloudBrainBoard) + m.Group("/cloudbrain", func() { + m.Get("/status_analysis", repo.GetCloudbrainsStatusAnalysis) + }) }, operationReq) // Users m.Group("/users", func() { diff --git a/routers/api/v1/repo/cloudbrain_dashboard.go b/routers/api/v1/repo/cloudbrain_dashboard.go index 2090a2cf2..47a64b5aa 100644 --- a/routers/api/v1/repo/cloudbrain_dashboard.go +++ b/routers/api/v1/repo/cloudbrain_dashboard.go @@ -11,6 +11,16 @@ import ( "github.com/360EntSecGroup-Skylar/excelize/v2" ) +type CloudbrainsStatusAnalysis struct { + JobWaitingCount int64 `json:"jobWaitingCount"` + JobRunningCount int64 `json:"jobRunningCount"` + JobStoppedCount int64 `json:"jobStoppedCount"` + JobCompletedCount int64 `json:"jobCompletedCount"` + JobFailedCount int64 `json:"jobFailedCount"` + JobKilledCount int64 `json:"jobKilledCount"` + JobInitCount int64 `json:"jobInitCount"` +} + func DownloadCloudBrainBoard(ctx *context.Context) { page := 1 @@ -133,3 +143,51 @@ func getBrainWaitTime(rs *models.CloudbrainInfo) string { return models.ConvertDurationToStr(int64(waitTime)) } } +func GetCloudbrainsStatusAnalysis(ctx *context.Context) { + jobWaitingCount, err := models.GetJobWaitingCount() + if err != nil { + log.Error("Can not query jobWaitingCount.", err) + return + } + jobRunningCount, err := models.GetJobRunningCount() + if err != nil { + log.Error("Can not query jobRunningCount.", err) + return + } + jobStoppedCount, err := models.GetJobStoppedCount() + if err != nil { + log.Error("Can not query jobStoppedCount.", err) + return + } + jobCompletedCount, err := models.GetJobCompletedCount() + if err != nil { + log.Error("Can not query jobCompletedCount.", err) + return + } + jobFailedCount, err := models.GetJobFailedCount() + if err != nil { + log.Error("Can not query jobFailedCount.", err) + return + } + jobKilledCount, err := models.GetJobKilledCount() + if err != nil { + log.Error("Can not query jobKilledCount.", err) + return + } + jobInitCount, err := models.GetJobInitCount() + if err != nil { + log.Error("Can not query jobInitCount.", err) + return + } + + cloudbrainsStatusAnalysis := CloudbrainsStatusAnalysis{ + JobWaitingCount: jobWaitingCount, + JobRunningCount: jobRunningCount, + JobStoppedCount: jobStoppedCount, + JobCompletedCount: jobCompletedCount, + JobFailedCount: jobFailedCount, + JobKilledCount: jobKilledCount, + JobInitCount: jobInitCount, + } + ctx.JSON(http.StatusOK, cloudbrainsStatusAnalysis) +} From fe25a065950183f6f9e85913ad38fa4293a72553 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 25 May 2022 16:30:21 +0800 Subject: [PATCH 49/96] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- web_src/js/components/UserAnalysis.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 79a593137..02027288b 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -279,7 +279,7 @@ value_time: '', search:'', data:'', - columns: [{title: 'ID',key: 'ID'},{title: '用户名',key: 'Name'},{title: 'PR数',key: 'CodeMergeCount'},{title: 'commit数',key:'CommitCount'},{title: '提出任务数',key: 'IssueCount'},{title: '评论数',key: 'CommentCount'},{title: '关注项目数',key: 'FocusRepoCount'},{title: '点赞项目数',key: 'StarRepoCount'},{title: '登录次数',key: 'LoginCount'},{title:'关注者数',key:'WatchedCount'},{title:'commit代码行数',key:'CommitCodeSize'},{title:'已解决任务数',key:'SolveIssueCount'},{title:'百科页面贡献次数',key:'EncyclopediasCount'},{title:'创建项目',key:'CreateRepoCount'},{title:'用户注册时间',key:'RegistDate'},{title:'云脑任务数',key:'CloudBrainTaskNum'},{title:'云脑运行时间(小时)',key:'CloudBrainRunTime'},{title:'上传(提交)数据集文件数',key:'CommitDatasetNum'},{title:'提交模型数',key:'CommitModelCount'},{title:'归一化用户指数',key:'UserIndex'},{title:'用户指数',key:'UserIndexPrimitive'},{title:'关注他人数',key:'FocusOtherUser'},{title:'收藏数据集',key:'CollectDataset'},{title:'被收藏数据集',key:'CollectedDataset'},{title:'被推荐数据集数',key:'RecommendDataset'},{title:'收藏镜像数',key:'CollectImage'},{title:'被收藏镜像数',key:'CollectedImage'},{title:'被推荐镜像数',key:'RecommendImage'},,{title:'Email',key:'Email'},{title:'用户所在地址',key:'UserLocation'}{title:'系统统计时间',key:'CountDate'}], + columns: [{title: 'ID',key: 'ID'},{title: '用户名',key: 'Name'},{title: 'PR数',key: 'CodeMergeCount'},{title: 'commit数',key:'CommitCount'},{title: '提出任务数',key: 'IssueCount'},{title: '评论数',key: 'CommentCount'},{title: '关注项目数',key: 'FocusRepoCount'},{title: '点赞项目数',key: 'StarRepoCount'},{title: '登录次数',key: 'LoginCount'},{title:'关注者数',key:'WatchedCount'},{title:'commit代码行数',key:'CommitCodeSize'},{title:'已解决任务数',key:'SolveIssueCount'},{title:'百科页面贡献次数',key:'EncyclopediasCount'},{title:'创建项目',key:'CreateRepoCount'},{title:'用户注册时间',key:'RegistDate'},{title:'云脑任务数',key:'CloudBrainTaskNum'},{title:'云脑运行时间(小时)',key:'CloudBrainRunTime'},{title:'上传(提交)数据集文件数',key:'CommitDatasetNum'},{title:'提交模型数',key:'CommitModelCount'},{title:'归一化用户指数',key:'UserIndex'},{title:'用户指数',key:'UserIndexPrimitive'},{title:'关注他人数',key:'FocusOtherUser'},{title:'收藏数据集',key:'CollectDataset'},{title:'被收藏数据集',key:'CollectedDataset'},{title:'被推荐数据集数',key:'RecommendDataset'},{title:'收藏镜像数',key:'CollectImage'},{title:'被收藏镜像数',key:'CollectedImage'},{title:'被推荐镜像数',key:'RecommendImage'},{title:'Email',key:'Email'},{title:'用户所在地址',key:'UserLocation'},{title:'系统统计时间',key:'CountDate'}], blob:'', fileName:'', dynamic:7, From 150850e0acd2086f406ef0975d035ddf101d8831 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 25 May 2022 16:38:01 +0800 Subject: [PATCH 50/96] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9=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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index b14170efb..2b29779aa 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -112,7 +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.RecommendImage")) + excelHeader = append(excelHeader, ctx.Tr("user.static.location")) excelHeader = append(excelHeader, ctx.Tr("user.static.registdate")) excelHeader = append(excelHeader, ctx.Tr("user.static.countdate")) From 7bbbbd316fa6d66f38548851fff9adb7da9a79c5 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 25 May 2022 16:41:30 +0800 Subject: [PATCH 51/96] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9=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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 8919efcf0..2d6649e98 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -477,6 +477,7 @@ func QueryUserStaticDataForUserDefine(opts *UserBusinessAnalysisQueryOptions, wi dateRecord.Email = userRecord.Email dateRecord.RegistDate = userRecord.CreatedUnix dateRecord.Name = userRecord.Name + dateRecord.UserLocation = userRecord.Location dateRecord.GiteaAgeMonth = subMonth(currentTimeNow, userRecord.CreatedUnix.AsTime()) dateRecord.CodeMergeCount = getMapValue(dateRecord.ID, CodeMergeCountMap) @@ -973,7 +974,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.Name = userRecord.Name dateRecord.GiteaAgeMonth = subMonth(currentTimeNow, userRecord.CreatedUnix.AsTime()) dateRecord.DataDate = DataDate - + dateRecord.UserLocation = userRecord.Location dateRecord.CodeMergeCount = getMapValue(dateRecord.ID, CodeMergeCountMap) dateRecord.CommitCount = getMapValue(dateRecord.ID, CommitCountMap) dateRecord.IssueCount = getMapValue(dateRecord.ID, IssueCountMap) From 3c1d4508c773b79998fe8ece54f311ded862cd89 Mon Sep 17 00:00:00 2001 From: liuzx Date: Wed, 25 May 2022 16:56:15 +0800 Subject: [PATCH 52/96] fix-2050 --- routers/repo/modelarts.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index c5a4de645..ced0da8f2 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -1471,8 +1471,8 @@ func obsMkdir(dir string) error { } func paramCheckCreateTrainJob(form auth.CreateModelArtsTrainJobForm) error { - if !strings.HasSuffix(form.BootFile, ".py") { - log.Error("the boot file(%s) must be a python file", form.BootFile) + if !strings.HasSuffix(strings.TrimSpace(form.BootFile), ".py") { + log.Error("the boot file(%s) must be a python file", strings.TrimSpace(form.BootFile)) return errors.New("启动文件必须是python文件") } @@ -1489,8 +1489,8 @@ func paramCheckCreateTrainJob(form auth.CreateModelArtsTrainJobForm) error { } func paramCheckCreateInferenceJob(form auth.CreateModelArtsInferenceJobForm) error { - if !strings.HasSuffix(form.BootFile, ".py") { - log.Error("the boot file(%s) must be a python file", form.BootFile) + if !strings.HasSuffix(strings.TrimSpace(form.BootFile), ".py") { + log.Error("the boot file(%s) must be a python file", strings.TrimSpace(form.BootFile)) return errors.New("启动文件必须是python文件") } From f4795f39ea5c00fbf116427bc7d30f3cb5f41669 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 25 May 2022 17:00:41 +0800 Subject: [PATCH 53/96] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_en-US.ini | 2 +- options/locale/locale_zh-CN.ini | 2 +- routers/repo/user_data_analysis.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 7b7f22bce..546127183 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -530,7 +530,7 @@ static.public.user_business_analysis_last30_day=Last_30_day static.public.user_business_analysis_last_month=Last_Month static.public.user_business_analysis_yesterday=Yesterday static.public.user_business_analysis_all=All - +static.downloadinfo=Due to the large amount of data generated in the customized time period and long calculation time, please download and export the data from the following address and export the data download address: metrics.sheetname=User Trend Analysis metrics.date=Count Date metrics.newregistuser=New registered user diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index cc3b5ddd9..c76dee610 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -535,7 +535,7 @@ static.public.user_business_analysis_last30_day=近30天 static.public.user_business_analysis_last_month=上月 static.public.user_business_analysis_yesterday=昨天 static.public.user_business_analysis_all=所有 - +static.downloadinfo=因自定义时间段产生的数据量比较大,计算时间比较长,请您从如下地址下载导出数据,\n导出数据下载地址: metrics.sheetname=用户趋势分析 metrics.date=日期 metrics.newregistuser=新增注册用户 diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 2b29779aa..1c79c9e93 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -601,7 +601,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { filename := sheetName + "_" + startDate + "_" + endDate + ".xlsx" os.Remove(setting.AppDataPath + Excel_File_Path + filename) go writeFileToDisk(ctx, count, re, filename) - ctx.JSON(http.StatusOK, setting.AppURL+"api/v1/download_user_define_file?filename="+filename) + ctx.JSON(http.StatusOK, ctx.Tr("user.static.downloadinfo")+setting.AppURL+"api/v1/download_user_define_file?filename="+filename) } else { mapInterface := make(map[string]interface{}) re, count := models.QueryUserStaticDataPage(pageOpts) From 8a8a5b1846ae839b7429f85ede14b4c07f02454e Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 25 May 2022 17:04:25 +0800 Subject: [PATCH 54/96] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_zh-CN.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index c76dee610..99b9e6df3 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -535,7 +535,7 @@ static.public.user_business_analysis_last30_day=近30天 static.public.user_business_analysis_last_month=上月 static.public.user_business_analysis_yesterday=昨天 static.public.user_business_analysis_all=所有 -static.downloadinfo=因自定义时间段产生的数据量比较大,计算时间比较长,请您从如下地址下载导出数据,\n导出数据下载地址: +static.downloadinfo=因自定义时间段产生的数据量比较大,计算时间比较长,请您从如下地址下载导出数据,
导出数据下载地址: metrics.sheetname=用户趋势分析 metrics.date=日期 metrics.newregistuser=新增注册用户 From d075d81b4abec9b6472b9d1fa88cf13169f3be0a Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 25 May 2022 17:05:19 +0800 Subject: [PATCH 55/96] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_zh-CN.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 99b9e6df3..6754e3b1d 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -535,7 +535,7 @@ static.public.user_business_analysis_last30_day=近30天 static.public.user_business_analysis_last_month=上月 static.public.user_business_analysis_yesterday=昨天 static.public.user_business_analysis_all=所有 -static.downloadinfo=因自定义时间段产生的数据量比较大,计算时间比较长,请您从如下地址下载导出数据,
导出数据下载地址: +static.downloadinfo=因自定义时间段产生的数据量比较大,计算时间比较长,请您从如下地址下载导出数据,导出数据下载地址: metrics.sheetname=用户趋势分析 metrics.date=日期 metrics.newregistuser=新增注册用户 From bb1f87a033de13c8274790be4718aa9e545e6bd9 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 25 May 2022 17:11:13 +0800 Subject: [PATCH 56/96] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9=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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 2d6649e98..6d438ab0a 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -1154,7 +1154,7 @@ func getUserIndexFromAnalysisAll(dateRecord UserBusinessAnalysisAll, ParaWeight // 登录次数 0.10 result = float64(dateRecord.CodeMergeCount) * getParaWeightValue("CodeMergeCount", ParaWeight, 0.2) result += float64(dateRecord.CommitCount) * getParaWeightValue("CommitCount", ParaWeight, 0.2) - log.Info("1 result=" + fmt.Sprint(result)) + //log.Info("1 result=" + fmt.Sprint(result)) result += float64(dateRecord.IssueCount) * getParaWeightValue("IssueCount", ParaWeight, 0.2) result += float64(dateRecord.CommentCount) * getParaWeightValue("CommentCount", ParaWeight, 0.2) result += float64(dateRecord.FocusRepoCount) * getParaWeightValue("FocusRepoCount", ParaWeight, 0.1) @@ -1237,7 +1237,7 @@ func getUserIndex(dateRecord UserBusinessAnalysis, ParaWeight map[string]float64 // 登录次数 0.10 result = float64(dateRecord.CodeMergeCount) * getParaWeightValue("CodeMergeCount", ParaWeight, 0.2) result += float64(dateRecord.CommitCount) * getParaWeightValue("CommitCount", ParaWeight, 0.2) - log.Info("2 result=" + fmt.Sprint(result)) + //log.Info("2 result=" + fmt.Sprint(result)) result += float64(dateRecord.IssueCount) * getParaWeightValue("IssueCount", ParaWeight, 0.2) result += float64(dateRecord.CommentCount) * getParaWeightValue("CommentCount", ParaWeight, 0.2) result += float64(dateRecord.FocusRepoCount) * getParaWeightValue("FocusRepoCount", ParaWeight, 0.1) From deba9009e6d33753d3d6aa1afd799986799e95a7 Mon Sep 17 00:00:00 2001 From: liuzx Date: Wed, 25 May 2022 18:06:47 +0800 Subject: [PATCH 57/96] update --- models/cloudbrain_static.go | 46 +++++++++++--------------- routers/api/v1/repo/cloudbrain_dashboard.go | 50 +++-------------------------- 2 files changed, 23 insertions(+), 73 deletions(-) diff --git a/models/cloudbrain_static.go b/models/cloudbrain_static.go index de3575632..31f66d4fc 100644 --- a/models/cloudbrain_static.go +++ b/models/cloudbrain_static.go @@ -1,30 +1,22 @@ package models -func GetJobWaitingCount() (int64, error) { - countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(JobWaiting) + "'" - return x.SQL(countSql).Count() -} -func GetJobStoppedCount() (int64, error) { - countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(JobStopped) + "'" - return x.SQL(countSql).Count() -} -func GetJobCompletedCount() (int64, error) { - countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(ModelArtsTrainJobCompleted) + "'" - return x.SQL(countSql).Count() -} -func GetJobFailedCount() (int64, error) { - countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(JobFailed) + "'" - return x.SQL(countSql).Count() -} -func GetJobRunningCount() (int64, error) { - countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(JobRunning) + "'" - return x.SQL(countSql).Count() -} -func GetJobKilledCount() (int64, error) { - countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(ModelArtsTrainJobKilled) + "'" - return x.SQL(countSql).Count() -} -func GetJobInitCount() (int64, error) { - countSql := "SELECT count(*) FROM " + "public.cloudbrain where status ='" + string(ModelArtsTrainJobInit) + "'" - return x.SQL(countSql).Count() +import "code.gitea.io/gitea/modules/log" + +func GetAllStatusCloudBrain() map[string]int { + sess := x.NewSession() + defer sess.Close() + cloudbrains := make([]*CloudbrainInfo, 0) + if err := sess.Table(&Cloudbrain{}).Unscoped(). + Find(&cloudbrains); err != nil { + log.Info("find error.") + } + cloudBrainStatusResult := make(map[string]int) + for _, cloudbrain := range cloudbrains { + if _, ok := cloudBrainStatusResult[cloudbrain.Status]; !ok { + cloudBrainStatusResult[cloudbrain.Status] = 1 + } else { + cloudBrainStatusResult[cloudbrain.Status] += 1 + } + } + return cloudBrainStatusResult } diff --git a/routers/api/v1/repo/cloudbrain_dashboard.go b/routers/api/v1/repo/cloudbrain_dashboard.go index 47a64b5aa..0710a21e4 100644 --- a/routers/api/v1/repo/cloudbrain_dashboard.go +++ b/routers/api/v1/repo/cloudbrain_dashboard.go @@ -144,50 +144,8 @@ func getBrainWaitTime(rs *models.CloudbrainInfo) string { } } func GetCloudbrainsStatusAnalysis(ctx *context.Context) { - jobWaitingCount, err := models.GetJobWaitingCount() - if err != nil { - log.Error("Can not query jobWaitingCount.", err) - return - } - jobRunningCount, err := models.GetJobRunningCount() - if err != nil { - log.Error("Can not query jobRunningCount.", err) - return - } - jobStoppedCount, err := models.GetJobStoppedCount() - if err != nil { - log.Error("Can not query jobStoppedCount.", err) - return - } - jobCompletedCount, err := models.GetJobCompletedCount() - if err != nil { - log.Error("Can not query jobCompletedCount.", err) - return - } - jobFailedCount, err := models.GetJobFailedCount() - if err != nil { - log.Error("Can not query jobFailedCount.", err) - return - } - jobKilledCount, err := models.GetJobKilledCount() - if err != nil { - log.Error("Can not query jobKilledCount.", err) - return - } - jobInitCount, err := models.GetJobInitCount() - if err != nil { - log.Error("Can not query jobInitCount.", err) - return - } - - cloudbrainsStatusAnalysis := CloudbrainsStatusAnalysis{ - JobWaitingCount: jobWaitingCount, - JobRunningCount: jobRunningCount, - JobStoppedCount: jobStoppedCount, - JobCompletedCount: jobCompletedCount, - JobFailedCount: jobFailedCount, - JobKilledCount: jobKilledCount, - JobInitCount: jobInitCount, - } - ctx.JSON(http.StatusOK, cloudbrainsStatusAnalysis) + cloudBrainStatusResult := models.GetAllStatusCloudBrain() + ctx.JSON(http.StatusOK, map[string]interface{}{ + "cloudBrainStatusResult": cloudBrainStatusResult, + }) } From ce5e62452252146899318d1b9a67a9a4de125479 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 25 May 2022 18:23:02 +0800 Subject: [PATCH 58/96] fix issue --- web_src/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/index.js b/web_src/js/index.js index b7434885e..b9e7165cf 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -3923,7 +3923,7 @@ function initVueDataset() { this.getTypeList() if (!!document.getElementById('dataset-repolink-init')) { - this.cloudbrainType = location.href.indexOf('cloudbrain/train-job/create') !== -1 ? 0 : 1 + this.cloudbrainType = location.href.indexOf('cloudbrain') !== -1 ? 0 : 1 this.getCurrentRepoDataset(this.repolink, this.cloudbrainType) } From 09879828aade23f7ca85735e572e85e781d3476b Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 26 May 2022 08:56:36 +0800 Subject: [PATCH 59/96] =?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/home.go | 19 ++++++++++++++----- templates/explore/repo_right.tmpl | 2 +- templates/user/dashboard/repolist.tmpl | 4 ++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/routers/home.go b/routers/home.go index 09fe97dc6..2f37357e4 100755 --- a/routers/home.go +++ b/routers/home.go @@ -259,7 +259,11 @@ func ExploreRepos(ctx *context.Context) { ctx.Data["PageIsExplore"] = true ctx.Data["PageIsExploreRepositories"] = true ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled - + pictureInfo, err := getImageInfo("dashboard-picture") + if err == nil && len(pictureInfo) > 0 { + ctx.Data["image_url"] = pictureInfo[0]["url"] + ctx.Data["image_link"] = pictureInfo[0]["image_link"] + } var ownerID int64 if ctx.User != nil && !ctx.User.IsAdmin { ownerID = ctx.User.ID @@ -434,7 +438,11 @@ func ExploreUsers(ctx *context.Context) { ctx.Data["PageIsExplore"] = true ctx.Data["PageIsExploreUsers"] = true ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled - + pictureInfo, err := getImageInfo("explore-user-picture") + if err == nil && len(pictureInfo) > 0 { + ctx.Data["image_url"] = pictureInfo[0]["url"] + ctx.Data["image_link"] = pictureInfo[0]["image_link"] + } RenderUserSearch(ctx, &models.SearchUserOptions{ Actor: ctx.User, Type: models.UserTypeIndividual, @@ -668,8 +676,9 @@ func getRecommendOrg() ([]map[string]interface{}, error) { } return resultOrg, nil } -func getImageInfo() ([]map[string]interface{}, error) { - url := setting.RecommentRepoAddr + "picture_info" + +func getImageInfo(filename string) ([]map[string]interface{}, error) { + url := setting.RecommentRepoAddr + filename result, err := repository.RecommendFromPromote(url) if err != nil { @@ -759,7 +768,7 @@ func RecommendHomeInfo(ctx *context.Context) { if err != nil { log.Info("error." + err.Error()) } - resultImage, err := getImageInfo() + resultImage, err := getImageInfo("picture_info") if err != nil { log.Info("error." + err.Error()) } diff --git a/templates/explore/repo_right.tmpl b/templates/explore/repo_right.tmpl index 5e05e797b..d4eebbe6d 100644 --- a/templates/explore/repo_right.tmpl +++ b/templates/explore/repo_right.tmpl @@ -1,4 +1,4 @@ - +