From 26a2eed89f545045d18f9683aca0b668c68ab0d2 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 11 May 2022 16:14:52 +0800 Subject: [PATCH 1/3] =?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/api/v1/repo/repo_dashbord.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index 95c0e399e1..e2bd15e1fd 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -573,6 +573,9 @@ func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, p } if ctx.QueryTrim("type") == "all" { baseName = baseName + ctx.Tr("repo.all") + } else if ctx.QueryTrim("type") == "last_month" { + baseName = baseName + beginTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT) + "_" + endTime.AddDate(0, 0, -2).Format(EXCEL_DATE_FORMAT) + } else { baseName = baseName + beginTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT) + "_" + endTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT) } @@ -587,6 +590,8 @@ func getSummaryFileName(ctx *context.Context, beginTime time.Time, endTime time. baseName = baseName + ctx.Tr("repo.all") } else if ctx.QueryTrim("type") == "current_year" { baseName = baseName + ctx.Tr("repo.current_year") + } else if ctx.QueryTrim("type") == "last_month" { + baseName = baseName + beginTime.Format(EXCEL_DATE_FORMAT) + "_" + endTime.AddDate(0, 0, -2).Format(EXCEL_DATE_FORMAT) } else { baseName = baseName + beginTime.Format(EXCEL_DATE_FORMAT) + "_" + endTime.AddDate(0, 0, -1).Format(EXCEL_DATE_FORMAT) } -- 2.34.1 From f6537aa9d1c908ee58d6584e96e4cf54366ff7b0 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 11 May 2022 17:31:02 +0800 Subject: [PATCH 2/3] =?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/api/v1/repo/repo_dashbord.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index e2bd15e1fd..08f4af64c1 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -240,6 +240,8 @@ func getEndOfMonthDates(beginTime time.Time, endTime time.Time) []string { } } + dates = append(dates, endTime.AddDate(0, 0, -1).Format(DATE_FORMAT)) + return dates } -- 2.34.1 From 0fd3a245752d78710a8c1ef3ca4c1c5bc6a7dc69 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Fri, 13 May 2022 09:45:32 +0800 Subject: [PATCH 3/3] =?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 --- modules/setting/setting.go | 2 ++ routers/api/v1/repo/repo_dashbord.go | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index eee539d0ca..f8b7965f2e 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -584,6 +584,7 @@ var ( GrowthCommit float64 GrowthComments float64 RecordBeginTime string + GrowthBeginTime string IgnoreMirrorRepo bool }{} @@ -1416,6 +1417,7 @@ 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.GrowthBeginTime = sec.Key("growth_beigin_time").MustString("2022-05-20") RadarMap.IgnoreMirrorRepo = sec.Key("ignore_mirror_repo").MustBool(true) } diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index 08f4af64c1..6d73600535 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -138,7 +138,7 @@ func GetProjectsSummaryData(ctx *context.Context) { var datas = make([]*ProjectSummaryBaseData, 0) - recordBeginTime, err := getRecordBeginTime() + recordBeginTime, err := getGrowthRecordBeginTime() if err != nil { log.Error("Can not get record begin time", err) ctx.Error(http.StatusBadRequest, ctx.Tr("repo.record_begintime_get_err")) @@ -388,7 +388,7 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) { func GetProjectsSummaryDataFile(ctx *context.Context) { - recordBeginTime, err := getRecordBeginTime() + recordBeginTime, err := getGrowthRecordBeginTime() if err != nil { log.Error("Can not get record begin time", err) ctx.Error(http.StatusBadRequest, ctx.Tr("repo.record_begintime_get_err")) @@ -957,6 +957,10 @@ func getRecordBeginTime() (time.Time, error) { return time.ParseInLocation(DATE_FORMAT, setting.RadarMap.RecordBeginTime, time.Local) } +func getGrowthRecordBeginTime() (time.Time, error) { + return time.ParseInLocation(DATE_FORMAT, setting.RadarMap.GrowthBeginTime, time.Local) +} + func getTotalPage(total int64, pageSize int) int { another := 0 -- 2.34.1