From c025c708fbdbf020be9216c844bf9309fe086023 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 17 Nov 2021 10:45:50 +0800 Subject: [PATCH 01/25] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E9=A1=B9=E7=9B=AE=E7=BB=9F=E8=AE=A1=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/setting/setting.go | 7 +++++-- routers/api/v1/repo/repo_dashbord.go | 10 ++-------- routers/repo/repo_statistic.go | 24 +++++++++++++++++------- services/mailer/mail.go | 16 ++++++++++++++++ 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 9f31612b6..c533eb924 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -547,8 +547,9 @@ var ( GrowthCommit float64 GrowthComments float64 RecordBeginTime string - Path string }{} + + Warn_Notify_Mails []string ) // DateLang transforms standard language locale name to corresponding value in datetime plugin. @@ -1292,6 +1293,9 @@ func NewContext() { ElkTimeFormat = sec.Key("ELKTIMEFORMAT").MustString("date_time") SetRadarMapConfig() + + sec = Cfg.Section("warn_mail") + Warn_Notify_Mails = strings.Split(sec.Key("mails").MustString(""), ",") } func SetRadarMapConfig() { @@ -1329,7 +1333,6 @@ func SetRadarMapConfig() { RadarMap.GrowthCommit = sec.Key("growth_commit").MustFloat64(0.2) RadarMap.GrowthComments = sec.Key("growth_comments").MustFloat64(0.2) RadarMap.RecordBeginTime = sec.Key("record_beigin_time").MustString("2021-11-05") - RadarMap.Path = sec.Key("PATH").MustString("data/projectborad") } diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index 041162039..8f45f6cac 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -4,8 +4,6 @@ import ( "fmt" "net/http" "net/url" - "os" - "path" "strconv" "time" @@ -175,10 +173,6 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) { var projectAnalysis = ctx.Tr("repo.repo_stat_inspect") fileName := getFileName(ctx, beginTime, endTime, projectAnalysis) - if err := os.MkdirAll(setting.RadarMap.Path, os.ModePerm); err != nil { - ctx.Error(http.StatusBadRequest, fmt.Errorf("Failed to create dir %s: %v", setting.AvatarUploadPath, err).Error()) - } - totalPage := getTotalPage(total, pageSize) f := excelize.NewFile() @@ -214,7 +208,7 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) { } func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, projectAnalysis string) string { - baseName := setting.RadarMap.Path + "/" + projectAnalysis + "_" + baseName := projectAnalysis + "_" if ctx.QueryTrim("q") != "" { baseName = baseName + ctx.QueryTrim("q") + "_" @@ -225,7 +219,7 @@ func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, p baseName = baseName + beginTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT) + "_" + endTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT) } frontName := baseName + ".xlsx" - return path.Base(frontName) + return frontName } func allProjectsPeroidHeader(ctx *context.Context) map[string]string { diff --git a/routers/repo/repo_statistic.go b/routers/repo/repo_statistic.go index 59cb5e4c7..066b29772 100755 --- a/routers/repo/repo_statistic.go +++ b/routers/repo/repo_statistic.go @@ -3,6 +3,8 @@ package repo import ( "time" + "code.gitea.io/gitea/services/mailer" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/normalization" @@ -26,14 +28,17 @@ func RepoStatisticDaily(date string) { log.Info("%s", date) log.Info("begin Repo Statistic") t, _ := time.Parse("2006-01-02", date) + warnEmailMessage := "项目统计信息入库失败,请尽快定位。" if err := models.DeleteRepoStatDaily(date); err != nil { log.Error("DeleteRepoStatDaily failed: %v", err.Error()) + mailer.SendWarnNotifyMail(setting.Warn_Notify_Mails, warnEmailMessage) return } repos, err := models.GetAllRepositories() if err != nil { log.Error("GetAllRepositories failed: %v", err.Error()) + mailer.SendWarnNotifyMail(setting.Warn_Notify_Mails, warnEmailMessage) return } @@ -47,7 +52,7 @@ func RepoStatisticDaily(date string) { var numDevMonths, numWikiViews, numContributor, numKeyContributor, numCommitsGrowth, numCommitLinesGrowth, numContributorsGrowth int64 repoGitStat, err := models.GetRepoKPIStats(repo) if err != nil { - log.Error("GetRepoKPIStats failed: %s", repo.Name) + log.Error("GetRepoKPIStats failed: %s", getDistinctProjectName(repo)) } else { numDevMonths = repoGitStat.DevelopAge numKeyContributor = repoGitStat.KeyContributors @@ -68,26 +73,26 @@ func RepoStatisticDaily(date string) { var numVersions int64 numVersions, err = models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{}) if err != nil { - log.Error("GetReleaseCountByRepoID failed(%s): %v", repo.Name, err) + log.Error("GetReleaseCountByRepoID failed(%s): %v", getDistinctProjectName(repo), err) } var datasetSize int64 datasetSize, err = getDatasetSize(repo) if err != nil { - log.Error("getDatasetSize failed(%s): %v", repo.Name, err) + log.Error("getDatasetSize failed(%s): %v", getDistinctProjectName(repo), err) } var numComments int64 numComments, err = models.GetCommentCountByRepoID(repo.ID) if err != nil { - log.Error("GetCommentCountByRepoID failed(%s): %v", repo.Name, err) + log.Error("GetCommentCountByRepoID failed(%s): %v", getDistinctProjectName(repo), err) } beginTime, endTime := getStatTime(date) var numVisits int numVisits, err = repository.AppointProjectView(repo.OwnerName, repo.Name, beginTime, endTime) if err != nil { - log.Error("AppointProjectView failed(%s): %v", repo.Name, err) + log.Error("AppointProjectView failed(%s): %v", getDistinctProjectName(repo), err) } repoStat := models.RepoStatistic{ @@ -151,8 +156,9 @@ func RepoStatisticDaily(date string) { } if _, err = models.InsertRepoStat(&repoStat); err != nil { - log.Error("InsertRepoStat failed(%s): %v", repo.Name, err) - log.Error("failed statistic: %s", repo.Name) + log.Error("InsertRepoStat failed(%s): %v", getDistinctProjectName(repo), err) + log.Error("failed statistic: %s", getDistinctProjectName(repo)) + mailer.SendWarnNotifyMail(setting.Warn_Notify_Mails, warnEmailMessage) continue } @@ -244,6 +250,10 @@ func RepoStatisticDaily(date string) { } +func getDistinctProjectName(repo *models.Repository) string { + return repo.OwnerName + "/" + repo.Name +} + func getDatasetSize(repo *models.Repository) (int64, error) { dataset, err := models.GetDatasetByRepo(repo) if err != nil { diff --git a/services/mailer/mail.go b/services/mailer/mail.go index e9395f130..ef7447be2 100755 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -115,6 +115,22 @@ func SendActivateEmailMail(locale Locale, u *models.User, email *models.EmailAdd SendAsync(msg) } +func SendWarnNotifyMail(emails []string, message string) { + if setting.MailService == nil { + log.Warn("SendWarnNotifyMail is being invoked but mail service hasn't been initialized") + return + } + if len(emails) == 0 { + log.Warn("SendWarnNotifyMail is being invoked but do not have email to send") + return + } + msg := NewMessage(emails, message, message) + msg.Info = fmt.Sprintf(message) + + SendAsync(msg) + +} + // SendRegisterNotifyMail triggers a notify e-mail by admin created a account. func SendRegisterNotifyMail(locale Locale, u *models.User) { if setting.MailService == nil { From 7a284db5006abbc55b0133dbd214e22ae88f6c05 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 17 Nov 2021 11:51:54 +0800 Subject: [PATCH 02/25] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E6=8B=A5=E6=9C=89=E8=80=85=E5=8D=95=E7=8B=AC=E4=B8=80=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/api/v1/repo/repo_dashbord.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index 8f45f6cac..9862a7744 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -178,6 +178,7 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) { f := excelize.NewFile() index := f.NewSheet(projectAnalysis) + f.DeleteSheet("Sheet1") for k, v := range allProjectsPeroidHeader(ctx) { f.SetCellValue(projectAnalysis, k, v) @@ -198,7 +199,6 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) { } f.SetActiveSheet(index) - f.DeleteSheet("Sheet1") ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(fileName)) ctx.Resp.Header().Set("Content-Type", "application/octet-stream") @@ -224,16 +224,16 @@ func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, p func allProjectsPeroidHeader(ctx *context.Context) map[string]string { - return map[string]string{"A1": ctx.Tr("admin.repos.id"), "B1": ctx.Tr("admin.repos.projectName"), "C1": ctx.Tr("admin.repos.isPrivate"), "D1": ctx.Tr("admin.repos.openi"), "E1": ctx.Tr("admin.repos.visit"), "F1": ctx.Tr("admin.repos.download"), "G1": ctx.Tr("admin.repos.pr"), "H1": ctx.Tr("admin.repos.commit"), - "I1": ctx.Tr("admin.repos.watches"), "J1": ctx.Tr("admin.repos.stars"), "K1": ctx.Tr("admin.repos.forks"), "L1": ctx.Tr("admin.repos.issues"), "M1": ctx.Tr("admin.repos.closedIssues"), "N1": ctx.Tr("admin.repos.contributor")} + return map[string]string{"A1": ctx.Tr("admin.repos.id"), "B1": ctx.Tr("admin.repos.projectName"), "C1": ctx.Tr("repo.owner"), "D1": ctx.Tr("admin.repos.isPrivate"), "E1": ctx.Tr("admin.repos.openi"), "F1": ctx.Tr("admin.repos.visit"), "G1": ctx.Tr("admin.repos.download"), "H1": ctx.Tr("admin.repos.pr"), "I1": ctx.Tr("admin.repos.commit"), + "J1": ctx.Tr("admin.repos.watches"), "K1": ctx.Tr("admin.repos.stars"), "L1": ctx.Tr("admin.repos.forks"), "M1": ctx.Tr("admin.repos.issues"), "N1": ctx.Tr("admin.repos.closedIssues"), "O1": ctx.Tr("admin.repos.contributor")} } func allProjectsPeroidValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string { - return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): constructDistinctName(rs), getCellName("C", row): getIsPrivateDisplay(rs.IsPrivate, ctx), getCellName("D", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), - getCellName("E", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("F", row): strconv.FormatInt(rs.NumDownloads, 10), getCellName("G", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("H", row): strconv.FormatInt(rs.NumCommits, 10), - getCellName("I", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("J", row): strconv.FormatInt(rs.NumStars, 10), getCellName("K", row): strconv.FormatInt(rs.NumForks, 10), getCellName("L", row): strconv.FormatInt(rs.NumIssues, 10), - getCellName("M", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("N", row): strconv.FormatInt(rs.NumContributor, 10), + return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.Name, getCellName("C", row): rs.OwnerName, getCellName("D", row): getIsPrivateDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), + getCellName("F", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("G", row): strconv.FormatInt(rs.NumDownloads, 10), getCellName("H", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("I", row): strconv.FormatInt(rs.NumCommits, 10), + getCellName("J", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("K", row): strconv.FormatInt(rs.NumStars, 10), getCellName("L", row): strconv.FormatInt(rs.NumForks, 10), getCellName("M", row): strconv.FormatInt(rs.NumIssues, 10), + getCellName("N", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("O", row): strconv.FormatInt(rs.NumContributor, 10), } } @@ -241,13 +241,6 @@ func getCellName(col string, row int) string { return col + strconv.Itoa(row) } -func constructDistinctName(rs *models.RepoStatistic) string { - if rs.OwnerName == "" { - return rs.Name - } - return rs.OwnerName + "/" + rs.Name -} - func getIsPrivateDisplay(private bool, ctx *context.Context) string { if private { return ctx.Tr("admin.repos.yes") From 119ddd3098968b6ceaf6d98a193ded36d4786046 Mon Sep 17 00:00:00 2001 From: avadesian Date: Wed, 17 Nov 2021 14:53:12 +0800 Subject: [PATCH 03/25] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=AF=94=E8=BE=83?= =?UTF-8?q?=E5=88=86=E6=94=AF=E6=97=B6=E5=BC=95=E5=85=A5=E7=9A=84tag?= =?UTF-8?q?=E6=B1=A1=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/git/repo_compare.go | 2 +- routers/repo/view.go | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/git/repo_compare.go b/modules/git/repo_compare.go index 5bc7f9ca5..8082a8400 100644 --- a/modules/git/repo_compare.go +++ b/modules/git/repo_compare.go @@ -32,7 +32,7 @@ func (repo *Repository) GetMergeBase(tmpRemote string, base, head string) (strin if tmpRemote != "origin" { tmpBaseName := "refs/remotes/" + tmpRemote + "/tmp_" + base // Fetch commit into a temporary branch in order to be able to handle commits and tags - _, err := NewCommand("fetch", tmpRemote, base+":"+tmpBaseName).RunInDir(repo.Path) + _, err := NewCommand("fetch", tmpRemote, base+":"+tmpBaseName,"--no-tags").RunInDir(repo.Path) if err == nil { base = tmpBaseName } diff --git a/routers/repo/view.go b/routers/repo/view.go index 8b9039087..50a53f68b 100755 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -824,24 +824,21 @@ func renderCode(ctx *context.Context) { */ baseGitRepo, err := git.OpenRepository(ctx.Repo.Repository.BaseRepo.RepoPath()) defer baseGitRepo.Close() + var compareInfo *git.CompareInfo if err != nil { log.Error("error open baseRepo:%s", ctx.Repo.Repository.BaseRepo.RepoPath()) ctx.Data["FetchUpstreamCnt"] = -1 // minus value indicates error } else { if _, error := baseGitRepo.GetBranch(ctx.Repo.BranchName); error == nil { //base repo has the same branch, then compare between current repo branch and base repo's branch - compareUrl := ctx.Repo.BranchName + "..." + ctx.Repo.Repository.BaseRepo.OwnerName + "/" + ctx.Repo.Repository.BaseRepo.Name + ":" + ctx.Repo.BranchName - ctx.SetParams("*", compareUrl) + compareInfo, err = baseGitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName, ctx.Repo.BranchName) ctx.Data["UpstreamSameBranchName"] = true } else { //else, compare between current repo branch and base repo's default branch - compareUrl := ctx.Repo.BranchName + "..." + ctx.Repo.Repository.BaseRepo.OwnerName + "/" + ctx.Repo.Repository.BaseRepo.Name + ":" + ctx.Repo.Repository.BaseRepo.DefaultBranch - ctx.SetParams("*", compareUrl) + compareInfo, err = baseGitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName, ctx.Repo.Repository.BaseRepo.DefaultBranch) ctx.Data["UpstreamSameBranchName"] = false } - _, _, headGitRepo, compareInfo, _, _ := ParseCompareInfo(ctx) - defer headGitRepo.Close() - if compareInfo != nil { + if err==nil && compareInfo != nil { if compareInfo.Commits != nil { log.Info("compareInfoCommits数量:%d", compareInfo.Commits.Len()) ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len() From ddba189ce34fca0038a25ad81ffece9e6a66b100 Mon Sep 17 00:00:00 2001 From: Gitea Date: Wed, 17 Nov 2021 15:08:06 +0800 Subject: [PATCH 04/25] modify code --- web_src/js/components/ProAnalysis.vue | 49 +++++++++++++++++----------------- web_src/js/components/UserAnalysis.vue | 4 +++ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/web_src/js/components/ProAnalysis.vue b/web_src/js/components/ProAnalysis.vue index 2a42f189c..eed722796 100755 --- a/web_src/js/components/ProAnalysis.vue +++ b/web_src/js/components/ProAnalysis.vue @@ -53,16 +53,6 @@ stripe > - - - - {{scope.row.name}} + + 任务完成比例 - {{tableDataIDTotal.issueClosedRatio * 100}}% + {{(tableDataIDTotal.issueClosedRatio * 100) | rounding}}% @@ -248,18 +245,18 @@
统计周期: - - - - - - - + + + + + + + td { + background-color:#D3D3D3!important; + opacity:1 + } .colorChange { background-color: #409effd6; color: #FFFF; diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 71e46bad5..2c1c81456 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -432,6 +432,10 @@ /deep/ .el-table { font-size: 12px; } + /deep/ .el-table tbody tr:hover>td { + background-color:#D3D3D3!important; + opacity:1 + } .colorChange { background-color: #409effd6; From 910aefb2a0bdff526ce34bb601862705fd97768d Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 17 Nov 2021 15:15:31 +0800 Subject: [PATCH 05/25] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82=E5=A2=9E=E5=8A=A0=E5=A4=B1=E8=B4=A5=E5=8F=91=E9=80=81?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8A=9F=E8=83=BD=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 +++++++--- routers/repo/user_data_analysis.go | 12 +++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index fb639459f..61821f973 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -246,7 +246,7 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus return userBusinessAnalysisReturnList, count } -func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, endTime time.Time, isReCount bool) { +func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, endTime time.Time, isReCount bool) error { log.Info("start to count other user info data") sess := x.NewSession() @@ -394,9 +394,13 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, dateRecord.CommitModelCount = 0 - statictisSess.Insert(&dateRecord) + _, err = statictisSess.Insert(&dateRecord) + if err != nil { + log.Info("insert daterecord failed." + err.Error()) + return err + } } - + return nil } func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime time.Time) { diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 134896177..8edecf836 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/services/mailer" "github.com/360EntSecGroup-Skylar/excelize/v2" ) @@ -142,10 +143,11 @@ func TimingCountDataByDateAndReCount(date string, isReCount bool) { //query wiki data log.Info("start to time count data") wikiMap := make(map[string]int) - + warnEmailMessage := "用户统计信息入库失败,请尽快定位。" repoList, err := models.GetAllRepositories() if err != nil { - log.Error("query repo error.") + log.Error("query repo error." + err.Error()) + mailer.SendWarnNotifyMail(setting.Warn_Notify_Mails, warnEmailMessage) return } log.Info("start to query wiki data") @@ -180,7 +182,11 @@ func TimingCountDataByDateAndReCount(date string, isReCount bool) { } } //other user info data - models.CounDataByDateAndReCount(wikiMap, startTime, endTime, isReCount) + 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) + } } func TimingCountDataByDate(date string) { From 6c6d6602760b52e9780fb03b65c44737c46be1b4 Mon Sep 17 00:00:00 2001 From: Gitea Date: Wed, 17 Nov 2021 15:38:28 +0800 Subject: [PATCH 06/25] modify code --- web_src/js/components/ProAnalysis.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_src/js/components/ProAnalysis.vue b/web_src/js/components/ProAnalysis.vue index eed722796..c9d44b3a6 100755 --- a/web_src/js/components/ProAnalysis.vue +++ b/web_src/js/components/ProAnalysis.vue @@ -182,7 +182,7 @@ 任务完成比例 - {{(tableDataIDTotal.issueClosedRatio * 100) | rounding}}% + {{Math.round(tableDataIDTotal.issueClosedRatio * 100) }}%
@@ -961,6 +961,7 @@ } }, filters:{ + rounding (value) { return Number(value).toFixed(2) }, From 9297bb602a63bcf77042e862b3d44b1bb80846f6 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 17 Nov 2021 16:00:58 +0800 Subject: [PATCH 07/25] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84sheet=E9=A1=B5=E9=9D=A2?= 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, 2 insertions(+) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 8edecf836..666a3a342 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -68,8 +68,10 @@ func QueryUserStaticDataPage(ctx *context.Context) { if IsReturnFile { //writer exec file. xlsx := excelize.NewFile() + xlsx.DeleteSheet("Sheet1") sheetName := ctx.Tr("user.static.sheetname") index := xlsx.NewSheet(sheetName) + dataHeader := map[string]string{ "A1": ctx.Tr("user.static.id"), "B1": ctx.Tr("user.static.name"), From d10b78741c4f4fdf06a359d40f7f9f3e6f75194e Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 17 Nov 2021 17:07:08 +0800 Subject: [PATCH 08/25] =?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 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 61821f973..2dbd86747 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -142,6 +142,22 @@ func QueryUserStaticData(startTime int64, endTime int64) []*UserBusinessAnalysis return userBusinessAnalysisReturnList } +func getLastCountDate() int64 { + statictisSess := xStatistic.NewSession() + defer statictisSess.Close() + statictisSess.Limit(1, 0) + userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) + if err := statictisSess.Table("user_business_analysis").OrderBy("countdate desc").Limit(1, 0). + Find(&userBusinessAnalysisList); err == nil { + for _, userRecord := range userBusinessAnalysisList { + return userRecord.CountDate - 10000 + } + } + currentTimeNow := time.Now() + pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) + return pageStartTime.Unix() +} + func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime)) @@ -149,8 +165,8 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus defer statictisSess.Close() currentTimeNow := time.Now() - pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) - pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) + 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 { @@ -159,10 +175,10 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus ) } cond = cond.And( - builder.Gte{"count_date": pageStartTime.Unix()}, + builder.Gte{"count_date": pageStartTime}, ) cond = cond.And( - builder.Lte{"count_date": pageEndTime.Unix()}, + builder.Lte{"count_date": pageEndTime}, ) count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) From c5e6c7e82f39d66a8513cca7aab4b959a8d146e5 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 17 Nov 2021 17:18:30 +0800 Subject: [PATCH 09/25] =?UTF-8?q?-m=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 2dbd86747..2fe38c792 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -147,11 +147,13 @@ func getLastCountDate() int64 { defer statictisSess.Close() statictisSess.Limit(1, 0) userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) - if err := statictisSess.Table("user_business_analysis").OrderBy("countdate desc").Limit(1, 0). + if err := statictisSess.Table("user_business_analysis").OrderBy("count_date desc").Limit(1, 0). Find(&userBusinessAnalysisList); err == nil { for _, userRecord := range userBusinessAnalysisList { return userRecord.CountDate - 10000 } + } else { + log.Info("query error." + err.Error()) } currentTimeNow := time.Now() pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) From 64cc4b126218c3b734788b413f0c1c7af8fb3fa8 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 18 Nov 2021 09:33:37 +0800 Subject: [PATCH 10/25] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=90=9C=E7=B4=A2=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE=E9=A2=98?= 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 2fe38c792..be22cc300 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -208,7 +208,7 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus resultMap := make(map[int64]*UserBusinessAnalysis) - if opts.Page >= 0 && opts.PageSize > 0 { + if opts.Page >= 0 && opts.PageSize > 0 && len(userBusinessAnalysisList) > 0 { var newAndCond = builder.NewCond() var newOrCond = builder.NewCond() for _, userRecord := range userBusinessAnalysisList { From e77dcc07cc8e615aba707c4c996e2952a2f81868 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 18 Nov 2021 10:05:37 +0800 Subject: [PATCH 11/25] =?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 | 17 ++++++++++------- options/locale/locale_en-US.ini | 4 ++-- options/locale/locale_zh-CN.ini | 1 + routers/repo/user_data_analysis.go | 28 ++++++++++++++++++++++------ 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index be22cc300..9e9bf7f3a 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -82,6 +82,7 @@ type UserBusinessAnalysisQueryOptions struct { SortType string StartTime int64 EndTime int64 + IsAll bool } type UserBusinessAnalysisList []*UserBusinessAnalysis @@ -162,7 +163,7 @@ func getLastCountDate() int64 { func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { - log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime)) + log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime) + " isAll=" + fmt.Sprint(opts.IsAll)) statictisSess := xStatistic.NewSession() defer statictisSess.Close() @@ -219,12 +220,14 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus newAndCond = newAndCond.And( newOrCond, ) - newAndCond = newAndCond.And( - builder.Gte{"count_date": opts.StartTime}, - ) - newAndCond = newAndCond.And( - builder.Lte{"count_date": opts.EndTime}, - ) + if !opts.IsAll { + newAndCond = newAndCond.And( + builder.Gte{"count_date": opts.StartTime}, + ) + newAndCond = newAndCond.And( + builder.Lte{"count_date": opts.EndTime}, + ) + } userBusinessAnalysisList = make([]*UserBusinessAnalysis, 0) if err := statictisSess.Table("user_business_analysis").Where(newAndCond). diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index cac2153bb..b54ca18f2 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -420,7 +420,7 @@ static.createrepocount=Create Repo Count static.openiindex=OpenI Index static.registdate=Regist Date static.countdate=Count Date - +static.all=All [settings] profile = Profile @@ -815,7 +815,7 @@ get_repo_stat_error=Can not get the statistics of the repository. get_repo_info_error=Can not get the information of the repository. generate_statistic_file_error=Fail to generate file. repo_stat_inspect=ProjectAnalysis -all=all +all=All modelarts.notebook=Debug Task modelarts.train_job=Train Task modelarts.train_job.new_debug= New Debug Task diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 9918d47e0..7da672c0d 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -423,6 +423,7 @@ static.createrepocount=创建项目数 static.openiindex=OpenI指数 static.registdate=用户注册时间 static.countdate=系统统计时间 +static.all=所有 [settings] profile=个人信息 account=账号 diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 666a3a342..168a6419b 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -40,12 +40,21 @@ func QueryUserStaticDataPage(ctx *context.Context) { } userName := ctx.Query("userName") IsReturnFile := ctx.QueryBool("IsReturnFile") - log.Info("startDate=" + startDate + " endDate=" + endDate + " userName=" + userName + " page=" + fmt.Sprint(page)) - startTime, _ := time.Parse("2006-01-02", startDate) - endTime, _ := time.Parse("2006-01-02", endDate) - endTime = endTime.AddDate(0, 0, 1) - log.Info("startTime=" + fmt.Sprint(startTime.Unix()) + " endDate=" + fmt.Sprint(endTime.Unix())) + var startTime time.Time + var endTime time.Time + var isAll bool + if startDate == "all" { + isAll = true + startTime = time.Now() + endTime = time.Now() + } else { + startTime, _ = time.Parse("2006-01-02", startDate) + endTime, _ = time.Parse("2006-01-02", endDate) + endTime = endTime.AddDate(0, 0, 1) + isAll = false + log.Info("startTime=" + fmt.Sprint(startTime.Unix()) + " endDate=" + fmt.Sprint(endTime.Unix())) + } if IsReturnFile { page = -1 @@ -60,6 +69,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { UserName: userName, StartTime: startTime.Unix(), EndTime: endTime.Unix(), + IsAll: isAll, } mapInterface := make(map[string]interface{}) re, count := models.QueryUserStaticDataPage(pageOpts) @@ -120,7 +130,13 @@ func QueryUserStaticDataPage(ctx *context.Context) { //设置默认打开的表单 xlsx.SetActiveSheet(index) - filename := sheetName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx" + var filename string + if isAll { + filename = sheetName + "_" + ctx.Tr("user.static.all") + ".xlsx" + } else { + filename = sheetName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx" + } + if len(userName) > 0 { filename = sheetName + "_" + userName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx" } From 28c97e1a8bf4f72274b5c58595acd8e28ee95a4c Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 18 Nov 2021 10:27:34 +0800 Subject: [PATCH 12/25] =?UTF-8?q?OpenI=E6=8C=87=E6=95=B0=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E4=B8=A4=E4=BD=8D=E5=B0=8F=E6=95=B0?= 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 168a6419b..a621289ae 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -123,7 +123,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { xlsx.SetCellValue(sheetName, "L"+rows, userRecord.SolveIssueCount) xlsx.SetCellValue(sheetName, "M"+rows, userRecord.EncyclopediasCount) xlsx.SetCellValue(sheetName, "N"+rows, userRecord.CreateRepoCount) - xlsx.SetCellValue(sheetName, "O"+rows, userRecord.OpenIIndex) + xlsx.SetCellValue(sheetName, "O"+rows, fmt.Sprintf("%.2f", userRecord.OpenIIndex)) xlsx.SetCellValue(sheetName, "P"+rows, userRecord.RegistDate.Format("2006-01-02")) xlsx.SetCellValue(sheetName, "Q"+rows, time.Unix(userRecord.CountDate, 0).Format("2006-01-02")) } From 040156c31eab401cb46157ecee86ea1988e354af Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 18 Nov 2021 10:34:36 +0800 Subject: [PATCH 13/25] modify code --- web_src/js/components/DataAnalysis.vue | 17 ++-- web_src/js/components/ProAnalysis.vue | 6 +- web_src/js/components/UserAnalysis.vue | 142 +++++++++++++++++++++------------ 3 files changed, 102 insertions(+), 63 deletions(-) diff --git a/web_src/js/components/DataAnalysis.vue b/web_src/js/components/DataAnalysis.vue index 4c2657751..20411b3a5 100755 --- a/web_src/js/components/DataAnalysis.vue +++ b/web_src/js/components/DataAnalysis.vue @@ -69,18 +69,21 @@ if(tab.name=="third"){ // document.getElementById('usr').style.display="block" // document.getElementById("pro").style.display='none' - this.$refs.UserAnalysis.getUserList("all_usr",7) - + this.reload() this.isSecond = false this.isThird = true + this.$refs.UserAnalysis.getUpdateTime() + this.$refs.UserAnalysis.getUserList("all_usr",7) + + } - }, + }, - reload () { - this.isRouterAlive = false - this.$nextTick(() => (this.isRouterAlive = true)) - } + reload () { + this.isRouterAlive = false + this.$nextTick(() => (this.isRouterAlive = true)) + } }, } diff --git a/web_src/js/components/ProAnalysis.vue b/web_src/js/components/ProAnalysis.vue index c9d44b3a6..4ca7b620d 100755 --- a/web_src/js/components/ProAnalysis.vue +++ b/web_src/js/components/ProAnalysis.vue @@ -153,7 +153,7 @@ @@ -161,11 +161,11 @@ type_val:'', recordBeginTime:'', lastUpdatedTime:'', - currentPage:1, + page:1, pageSize:10, - params:{startDate:'',endDate:''}, + params:{startDate:'',endDate:'',page:1,pagesize:10,userName:''}, tableData: [], - + totalNum:0, pickerOptions: { }, value_time: '', @@ -200,8 +200,15 @@ return saveFileName }, - handleCurrentChange(currentPage){ - this.currentPage = currentPage; + handleCurrentChange(val){ + this.params.page = val + this.page = val + getUserList(this.type_val,this.dynamic) + + }, + resetPage(){ + this.page=1 + this.params.page = 1 }, formatDate(myyear,mymonth,myweekday) { // var myyear = this.date.getFullYear(); @@ -224,7 +231,14 @@ let days = (monthEndDate - monthStartDate)/(1000 * 60 * 60 * 24); return days; }, - + getUpdateTime(){ + this.$axios.get('../api/v1/projectboard/project',{ + params:this.params_pro + }).then((res)=>{ + this.recordBeginTime=res.data.recordBeginTime + this.lastUpdatedTime=res.data.lastUpdatedTime + }) + }, getUserList(type_val,index){ this.type_val = type_val this.dynamic = index; @@ -295,50 +309,64 @@ } case "all_usr":{ console.log("e:"+today) - this.params.startDate = this.recordBeginTime//this.formatDate(2000, 1, 1); // + this.params.startDate = 'all'//this.formatDate(2000, 1, 1); //this.recordBeginTime// this.params.endDate = today this.value_time=[] break } } }; - - this.$axios.get('../tool/query_user_static',{ + + this.$axios.get('../tool/query_user_static_page',{ params:this.params }).then((res)=>{ this.currentPage = 1 - this.tableData = res.data - console.log(" this.tableData:", this.tableData.length) - for(var i=0;i{ - this.recordBeginTime=res.data.recordBeginTime - this.lastUpdatedTime=res.data.lastUpdatedTime + this.tableData = res.data.data + // console.log("res.data:"+res.data.data) + + this.totalNum = res.data.count + console.log("res.count:"+res.data.count) }) + // this.$axios.get('../tool/query_user_static',{ + // params:this.params + // }).then((res)=>{ + // this.currentPage = 1 + // this.tableData = res.data + // console.log(" this.tableData:", this.tableData.length) + // for(var i=0;i !search || data.Name.toLowerCase().includes(search.toLowerCase())) + // var search = this.search; + // this.getUserList("all_usr",7) + // this.tableData = this.tableData.filter(data => !search || data.Name.toLowerCase().includes(search.toLowerCase())) - }, - goToDetailPage(pro_id,pro_name){ - sessionStorage.setItem("pro_id",pro_id); - sessionStorage.setItem("pro_name",pro_name); - document.getElementById("pro_main").style.display="none"; - document.getElementById("pro_detail").style.display="block"; + this.params.userName = this.search + this.params.page = 1 + this.page=1 + this.getUserList(this.type_val, this.dynamic) }, + // goToDetailPage(pro_id,pro_name){ + // sessionStorage.setItem("pro_id",pro_id); + // sessionStorage.setItem("pro_name",pro_name); + // document.getElementById("pro_main").style.display="none"; + // document.getElementById("pro_detail").style.display="block"; + + // }, tableHeaderStyle({row,column,rowIndex,columnIndex}){ if(rowIndex===0){ @@ -351,6 +379,11 @@ return 'background:#f5f5f6;color:#606266' } }, + + + }, + filters:{ + transformTimestamp(timestamp){ console.log("timestamp",timestamp) let a = new Date(timestamp*1000); @@ -365,9 +398,6 @@ console.log('dateString', dateString); // > dateString 2021-07-06 14:23 return dateString; }, - - }, - filters:{ // transformTimestamp(timestamp){ // var dateString= new Date(timestamp); @@ -386,9 +416,15 @@ }, watch:{ search(val){ + // if(!val){ + // this.getUserList("all_usr",7) + // } if(!val){ - this.getUserList("all_usr",7) - } + this.params.userName = this.search + this.params.page = 1 + this.page=1 + this.getUserList(this.type_val, this.dynamic) + } } }, } From ec732ff5dc4f0487a7362315cb3d2a7891ecef4c Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 18 Nov 2021 14:28:16 +0800 Subject: [PATCH 14/25] fix 872 --- modules/storage/obs.go | 22 +++++++++++----------- routers/repo/attachment.go | 8 +++++--- web_src/js/components/ObsUploader.vue | 1 + 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/modules/storage/obs.go b/modules/storage/obs.go index acf660e56..39312bfde 100755 --- a/modules/storage/obs.go +++ b/modules/storage/obs.go @@ -29,20 +29,20 @@ type FileInfo struct { } //check if has the object -//todo:修改查询方式 func ObsHasObject(path string) (bool, error) { hasObject := false - output, err := ObsCli.ListObjects(&obs.ListObjectsInput{Bucket: setting.Bucket}) - if err != nil { - log.Error("ListObjects failed:%v", err) - return hasObject, err - } - for _, obj := range output.Contents { - //obj.Key:attachment/0/1/019fd24e-4ef7-41cc-9f85-4a7b8504d958 - if path == obj.Key { - hasObject = true - break + input := &obs.GetObjectMetadataInput{} + input.Bucket = setting.Bucket + input.Key = path + _, err := ObsCli.GetObjectMetadata(input) + if err == nil { + hasObject = true + } else { + if obsError, ok := err.(obs.ObsError); ok { + log.Error("GetObjectMetadata failed(%d): %s", obsError.StatusCode, obsError.Message) + } else { + log.Error("%v", err.Error()) } } diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 2c082a289..8443d6488 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -360,6 +360,7 @@ func GetPresignedPutObjectURL(ctx *context.Context) { // AddAttachment response for add attachment record func AddAttachment(ctx *context.Context) { typeCloudBrain := ctx.QueryInt("type") + fileName := ctx.Query("file_name") err := checkTypeCloudBrain(typeCloudBrain) if err != nil { ctx.ServerError("checkTypeCloudBrain failed", err) @@ -375,7 +376,7 @@ func AddAttachment(ctx *context.Context) { return } } else { - has, err = storage.ObsHasObject(setting.BasePath + models.AttachmentRelativePath(uuid) + "/" + uuid) + has, err = storage.ObsHasObject(setting.BasePath + models.AttachmentRelativePath(uuid) + "/" + fileName) if err != nil { ctx.ServerError("ObsHasObject", err) return @@ -391,7 +392,7 @@ func AddAttachment(ctx *context.Context) { UUID: uuid, UploaderID: ctx.User.ID, IsPrivate: true, - Name: ctx.Query("file_name"), + Name: fileName, Size: ctx.QueryInt64("size"), DatasetID: ctx.QueryInt64("dataset_id"), Type: typeCloudBrain, @@ -479,6 +480,7 @@ func UpdateAttachmentDecompressState(ctx *context.Context) { func GetSuccessChunks(ctx *context.Context) { fileMD5 := ctx.Query("md5") typeCloudBrain := ctx.QueryInt("type") + fileName := ctx.Query("file_name") var chunks string err := checkTypeCloudBrain(typeCloudBrain) @@ -510,7 +512,7 @@ func GetSuccessChunks(ctx *context.Context) { return } } else { - isExist, err = storage.ObsHasObject(setting.BasePath + models.AttachmentRelativePath(fileChunk.UUID) + "/" + fileChunk.UUID) + isExist, err = storage.ObsHasObject(setting.BasePath + models.AttachmentRelativePath(fileChunk.UUID) + "/" + fileName) if err != nil { ctx.ServerError("ObsHasObject failed", err) return diff --git a/web_src/js/components/ObsUploader.vue b/web_src/js/components/ObsUploader.vue index 381cb7f95..b0796fe81 100755 --- a/web_src/js/components/ObsUploader.vue +++ b/web_src/js/components/ObsUploader.vue @@ -262,6 +262,7 @@ export default { params: { md5: file.uniqueIdentifier, type: CloudBrainType, + file_name: file.name, _csrf: csrf } }; From 9dd6f5de9c0c1cddf6827042235908c78cf7440c Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 18 Nov 2021 14:33:26 +0800 Subject: [PATCH 15/25] modify code --- web_src/js/components/DataAnalysis.vue | 3 ++- web_src/js/components/ProAnalysis.vue | 14 +++++++++++--- web_src/js/components/UserAnalysis.vue | 20 +++++++++++--------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/web_src/js/components/DataAnalysis.vue b/web_src/js/components/DataAnalysis.vue index 20411b3a5..4d771dbb1 100755 --- a/web_src/js/components/DataAnalysis.vue +++ b/web_src/js/components/DataAnalysis.vue @@ -20,7 +20,7 @@ 项目分析 - + @@ -72,6 +72,7 @@ this.reload() this.isSecond = false this.isThird = true + this.$refs.UserAnalysis.resetPage() this.$refs.UserAnalysis.getUpdateTime() this.$refs.UserAnalysis.getUserList("all_usr",7) diff --git a/web_src/js/components/ProAnalysis.vue b/web_src/js/components/ProAnalysis.vue index 4ca7b620d..b627e0d89 100755 --- a/web_src/js/components/ProAnalysis.vue +++ b/web_src/js/components/ProAnalysis.vue @@ -1072,13 +1072,21 @@ .btn:active{ background-color:#409effd6 ; } */ - /deep/ .el-date-picker { - width: 200px; - } + /* /deep/ .el-date-picker { + width: 250px; + } */ /deep/ .el-table tbody tr:hover>td { background-color:#D3D3D3!important; opacity:1 } + /deep/ .el-table { + font-size: 12px; + } + + /deep/ .el-range-separator{ + width: 20% !important; + } + .colorChange { background-color: #409effd6; color: #FFFF; diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 200f132f3..54ed18a37 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -163,7 +163,7 @@ lastUpdatedTime:'', page:1, pageSize:10, - params:{startDate:'',endDate:'',page:1,pagesize:10,userName:''}, + params:{startDate:'',endDate:'',page:1,pageSize:10,userName:''}, tableData: [], totalNum:0, pickerOptions: { @@ -203,7 +203,7 @@ handleCurrentChange(val){ this.params.page = val this.page = val - getUserList(this.type_val,this.dynamic) + this.getUserList(this.type_val,this.dynamic) }, resetPage(){ @@ -320,7 +320,6 @@ this.$axios.get('../tool/query_user_static_page',{ params:this.params }).then((res)=>{ - this.currentPage = 1 this.tableData = res.data.data // console.log("res.data:"+res.data.data) @@ -407,8 +406,8 @@ }, mounted() { - document.getElementById("all_usr").style.outline="none" - document.getElementById("all_usr").focus() + // document.getElementById("all_usr").style.outline="none" + // document.getElementById("all_usr").focus() this.getUserList("all_usr",7) }, created() { @@ -462,16 +461,19 @@ .btn:active{ background-color:#409effd6 ; } */ - /deep/ .el-date-picker { - width: 200px; - } + /* /deep/ .el-date-picker { + width: 220px; + } */ /deep/ .el-table { font-size: 12px; } /deep/ .el-table tbody tr:hover>td { background-color:#D3D3D3!important; opacity:1 - } + } + /deep/ .el-range-separator{ + width: 20% !important; + } .colorChange { background-color: #409effd6; From 192e7575629f646574bc9c8bc8bba3078d0828eb Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 18 Nov 2021 15:12:00 +0800 Subject: [PATCH 16/25] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E7=94=A8=E6=88=B7=E9=80=89=E6=8B=A9=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=B0=8F=E4=BA=8E2021-11-05=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E4=BF=AE=E6=AD=A3=E5=88=B02021-11-05?= 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, 4 insertions(+) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index a621289ae..dde11350e 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -50,6 +50,10 @@ func QueryUserStaticDataPage(ctx *context.Context) { endTime = time.Now() } else { startTime, _ = time.Parse("2006-01-02", startDate) + settingStartTime, _ := time.Parse("2006-01-02", setting.RadarMap.RecordBeginTime) + if startTime.Unix() < settingStartTime.Unix() { + startTime = settingStartTime + } endTime, _ = time.Parse("2006-01-02", endDate) endTime = endTime.AddDate(0, 0, 1) isAll = false From 93943231d07ef420032c08897514f0f260963a0b Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 18 Nov 2021 15:55:12 +0800 Subject: [PATCH 17/25] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4?= =?UTF-8?q?=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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index dde11350e..5c701eadb 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -53,6 +53,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { settingStartTime, _ := time.Parse("2006-01-02", setting.RadarMap.RecordBeginTime) if startTime.Unix() < settingStartTime.Unix() { startTime = settingStartTime + startDate = settingStartTime.Format("2006-01-02") } endTime, _ = time.Parse("2006-01-02", endDate) endTime = endTime.AddDate(0, 0, 1) @@ -135,6 +136,13 @@ func QueryUserStaticDataPage(ctx *context.Context) { //设置默认打开的表单 xlsx.SetActiveSheet(index) var filename string + + nowTime := time.Now() + nowZeroTime := time.Date(nowTime.Year(), nowTime.Month(), nowTime.Day(), 0, 0, 0, 0, nowTime.Location()) + if endTime.Unix() >= nowZeroTime.Unix() { + endDate = nowZeroTime.AddDate(0, 0, -1).Format("2006-01-02") + } + if isAll { filename = sheetName + "_" + ctx.Tr("user.static.all") + ".xlsx" } else { From beddae3ae51f8ffbe2db811167ea2521967fd4f3 Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 18 Nov 2021 16:35:08 +0800 Subject: [PATCH 18/25] modify code --- web_src/js/components/ProAnalysis.vue | 74 +++++++++++++++++++++++++--------- web_src/js/components/UserAnalysis.vue | 2 +- 2 files changed, 55 insertions(+), 21 deletions(-) diff --git a/web_src/js/components/ProAnalysis.vue b/web_src/js/components/ProAnalysis.vue index b627e0d89..882f610a4 100755 --- a/web_src/js/components/ProAnalysis.vue +++ b/web_src/js/components/ProAnalysis.vue @@ -153,7 +153,7 @@