From 512f48859d208e6eb2ab211fb8443efadd3ae19c Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 10:22:39 +0800 Subject: [PATCH 01/22] =?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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 00d8e3f8a..8694eee40 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -74,7 +74,7 @@ type UserBusinessAnalysis struct { //user Name string `xorm:"NOT NULL"` - DataDate string `xorm:"NULL"` + DataDate string `xorm:"NOT NULL"` } type UserBusinessAnalysisQueryOptions struct { @@ -264,7 +264,7 @@ func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime ti //endTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) end_unix := endTime.Unix() - CountDate := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 1, 0, 0, currentTimeNow.Location()) + CountDate := time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 0, 1, 0, 0, startTime.Location()) DataDate := startTime.Format("2006-01-02") CodeMergeCountMap := queryPullRequest(start_unix, end_unix) CommitCountMap := queryAction(start_unix, end_unix, 5) From 59975749182bb332072c639a7ddcecc288f7a538 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 10:36:51 +0800 Subject: [PATCH 02/22] =?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 | 12 ++++++++++-- routers/repo/user_data_analysis.go | 12 ++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 8694eee40..25e6dcc2f 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -245,7 +245,8 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus return userBusinessAnalysisReturnList, count } -func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime time.Time) { +func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, endTime time.Time, isReCount bool) { + log.Info("start to count other user info data") sess := x.NewSession() defer sess.Close() @@ -263,8 +264,11 @@ func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime ti //endTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) end_unix := endTime.Unix() + CountDate := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 1, 0, 0, currentTimeNow.Location()) + if isReCount { + CountDate = time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 0, 1, 0, 0, startTime.Location()) + } - CountDate := time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 0, 1, 0, 0, startTime.Location()) DataDate := startTime.Format("2006-01-02") CodeMergeCountMap := queryPullRequest(start_unix, end_unix) CommitCountMap := queryAction(start_unix, end_unix, 5) @@ -394,6 +398,10 @@ func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime ti } +func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime time.Time) { + CounDataByDateAndReCount(wikiCountMap, startTime, endTime, false) +} + func querySolveIssue(start_unix int64, end_unix int64) map[int64]int { //select issue_assignees.* from issue_assignees,issue where issue.is_closed=true and issue.id=issue_assignees.issue_id sess := x.NewSession() diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 3742cf67c..2421b0660 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -58,8 +58,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { ctx.JSON(http.StatusOK, mapInterface) } -func TimingCountDataByDate(date string) { - +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()) @@ -106,16 +105,17 @@ func TimingCountDataByDate(date string) { } } //other user info data - models.CounDataByDate(wikiMap, startTime, endTime) + models.CounDataByDateAndReCount(wikiMap, startTime, endTime, isReCount) +} +func TimingCountDataByDate(date string) { + TimingCountDataByDateAndReCount(date, true) } func TimingCountData() { - log.Info("start to time count data") currentTimeNow := time.Now() log.Info("current time:" + currentTimeNow.Format("2006-01-02 15:04:05")) startTime := currentTimeNow.AddDate(0, 0, -1).Format("2006-01-02") - - TimingCountDataByDate(startTime) + TimingCountDataByDateAndReCount(startTime, false) } From 533566982f3a9b7a442d847a16db154dd8c1cf88 Mon Sep 17 00:00:00 2001 From: Gitea Date: Tue, 16 Nov 2021 14:57:55 +0800 Subject: [PATCH 03/22] modify code --- templates/base/head_navbar.tmpl | 7 +++- templates/base/head_navbar_home.tmpl | 7 +++- web_src/js/components/ProAnalysis.vue | 66 ++++++++++++++++++++++++---------- web_src/js/components/UserAnalysis.vue | 2 +- 4 files changed, 60 insertions(+), 22 deletions(-) diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index 67d8fc1b7..49b3181e7 100755 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -37,7 +37,9 @@ {{.i18n.Tr "explore.users"}} {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} - {{.i18n.Tr "explore.data_analysis"}} + {{if .IsAdmin}} + {{.i18n.Tr "explore.data_analysis"}} + {{end}} {{else if .IsLandingPageHome}} @@ -53,6 +55,9 @@ {{.i18n.Tr "explore.users"}} {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} + {{if .IsAdmin}} + {{.i18n.Tr "explore.data_analysis"}} + {{end}} {{else if .IsLandingPageExplore}} diff --git a/templates/base/head_navbar_home.tmpl b/templates/base/head_navbar_home.tmpl index e334efba8..c94ff269f 100644 --- a/templates/base/head_navbar_home.tmpl +++ b/templates/base/head_navbar_home.tmpl @@ -29,7 +29,9 @@ {{.i18n.Tr "explore.users"}} {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} - {{.i18n.Tr "explore.data_analysis"}} + {{if .IsAdmin}} + {{.i18n.Tr "explore.data_analysis"}} + {{end}} {{else if .IsLandingPageHome}} @@ -45,6 +47,9 @@ {{.i18n.Tr "explore.users"}} {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} + {{if .IsAdmin}} + {{.i18n.Tr "explore.data_analysis"}} + {{end}} {{else if .IsLandingPageExplore}} diff --git a/web_src/js/components/ProAnalysis.vue b/web_src/js/components/ProAnalysis.vue index 8d4f25084..abe6f5904 100755 --- a/web_src/js/components/ProAnalysis.vue +++ b/web_src/js/components/ProAnalysis.vue @@ -8,18 +8,18 @@
统计周期: - - - - - - - + + + + + + +