From 512f48859d208e6eb2ab211fb8443efadd3ae19c Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 10:22:39 +0800 Subject: [PATCH 01/16] =?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/16] =?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 aff2711535ea2a7af50f67497115feeb72c0785f Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 15:40:35 +0800 Subject: [PATCH 03/16] =?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 --- options/locale/locale_en-US.ini | 19 +++++++++++ options/locale/locale_zh-CN.ini | 17 ++++++++++ routers/repo/user_data_analysis.go | 69 +++++++++++++++++++++++++++++++++++++- 3 files changed, 104 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index bc71693b8..f78dab9ed 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -402,6 +402,25 @@ form.name_reserved = The username '%s' is reserved. form.name_pattern_not_allowed = The pattern '%s' is not allowed in a username. form.name_chars_not_allowed = User name '%s' contains invalid characters. +static.sheetname=User Analysis +static.id=ID +static.name=User Name +static.codemergecount=PR Count +static.issuecount=Issue Count +static.commentcount=Comment Count +static.focusrepocount=Focus Repo Count +static.starrepocount=Repo Star Count +static.logincount=Login Count +static.watchedcount=Watched Count +static.commitcodesize=Commit Code Line +static.solveissuecount=Solve Issue Count +static.encyclopediascount=Encyclopedias Count +static.createrepocount=Create Repo Count +static.openiindex=OpenI Index +static.registdate=Regist Date +static.countdate=Count Date + + [settings] profile = Profile account = Account diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 6702a0434..0ecf1c1bf 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -405,6 +405,23 @@ form.name_reserved='%s' 用户名被保留。 form.name_pattern_not_allowed=用户名中不允许使用 "%s"。 form.name_chars_not_allowed=用户名 '%s' 包含无效字符。 +static.sheetname=用户分析 +static.id=ID +static.name=用户名 +static.codemergecount=PR数 +static.issuecount=提出任务数 +static.commentcount=评论数 +static.focusrepocount=关注项目数 +static.starrepocount=点赞项目数 +static.logincount=登录次数 +static.watchedcount=关注者数 +static.commitcodesize=commit代码行数 +static.solveissuecount=已解决任务数 +static.encyclopediascount=百科页面贡献次数 +static.createrepocount=创建项目数 +static.openiindex=OpenI指数 +static.registdate=用户注册时间 +static.countdate=系统统计时间 [settings] profile=个人信息 account=账号 diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 2421b0660..2fa94f626 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -3,6 +3,7 @@ package repo import ( "fmt" "net/http" + "strings" "time" "code.gitea.io/gitea/models" @@ -10,6 +11,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "github.com/xuri/excelize/v2" ) func QueryUserStaticData(ctx *context.Context) { @@ -35,6 +37,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { pageSize = setting.UI.IssuePagingNum } 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) @@ -55,7 +58,71 @@ func QueryUserStaticDataPage(ctx *context.Context) { re, count := models.QueryUserStaticDataPage(pageOpts) mapInterface["data"] = re mapInterface["count"] = count - ctx.JSON(http.StatusOK, mapInterface) + if IsReturnFile { + //writer exec file. + xlsx := excelize.NewFile() + sheetName := ctx.Tr("static.sheetname") + index := xlsx.NewSheet(sheetName) + dataHeader := map[string]string{ + "A1": ctx.Tr("user.static.id"), + "B1": ctx.Tr("user.static.name"), + "C1": ctx.Tr("user.static.codemergecount"), + "D1": ctx.Tr("user.static.issuecount"), + "E1": ctx.Tr("user.static.commentcount"), + "F1": ctx.Tr("user.static.focusrepocount"), + "G1": ctx.Tr("user.static.starrepocount"), + "H1": ctx.Tr("user.static.logincount"), + "I1": ctx.Tr("user.static.watchedcount"), + "J1": ctx.Tr("user.static.commitcodesize"), + "K1": ctx.Tr("user.static.solveissuecount"), + "L1": ctx.Tr("user.static.encyclopediascount"), + "M1": ctx.Tr("user.static.createrepocount"), + "N1": ctx.Tr("user.static.openiindex"), + "O1": ctx.Tr("user.static.registdate"), + "P1": ctx.Tr("user.static.countdate"), + } + for k, v := range dataHeader { + //设置单元格的值 + xlsx.SetCellValue(sheetName, k, v) + } + + for i, userRecord := range re { + rows := fmt.Sprint(i + 2) + + xlsx.SetCellValue(sheetName, "A"+rows, userRecord.ID) + xlsx.SetCellValue(sheetName, "B"+rows, userRecord.Name) + xlsx.SetCellValue(sheetName, "C"+rows, userRecord.CodeMergeCount) + xlsx.SetCellValue(sheetName, "D"+rows, userRecord.IssueCount) + xlsx.SetCellValue(sheetName, "E"+rows, userRecord.CommentCount) + xlsx.SetCellValue(sheetName, "F"+rows, userRecord.FocusRepoCount) + xlsx.SetCellValue(sheetName, "G"+rows, userRecord.StarRepoCount) + xlsx.SetCellValue(sheetName, "H"+rows, userRecord.LoginCount) + xlsx.SetCellValue(sheetName, "I"+rows, userRecord.WatchedCount) + xlsx.SetCellValue(sheetName, "J"+rows, userRecord.CommitCodeSize) + xlsx.SetCellValue(sheetName, "K"+rows, userRecord.SolveIssueCount) + xlsx.SetCellValue(sheetName, "L"+rows, userRecord.EncyclopediasCount) + xlsx.SetCellValue(sheetName, "M"+rows, userRecord.CreateRepoCount) + xlsx.SetCellValue(sheetName, "N"+rows, userRecord.OpenIIndex) + xlsx.SetCellValue(sheetName, "O"+rows, userRecord.RegistDate.Format("2006-01-02")) + xlsx.SetCellValue(sheetName, "P"+rows, time.Unix(userRecord.CountDate, 0).Format("2006-01-02")) + } + + //设置默认打开的表单 + xlsx.SetActiveSheet(index) + filename := sheetName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx" + if len(userName) > 0 { + filename = sheetName + "_" + userName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx" + } + + ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+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()) + } + + } else { + ctx.JSON(http.StatusOK, mapInterface) + } } func TimingCountDataByDateAndReCount(date string, isReCount bool) { From 4b6a7b4456dbb6d0fb8eb221f3698b8067e7015c Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 15:47:39 +0800 Subject: [PATCH 04/16] =?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 2fa94f626..b2f55083d 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - "github.com/xuri/excelize/v2" + "github.com/360EntSecGroup-Skylar/excelize/v2" ) func QueryUserStaticData(ctx *context.Context) { From eeb238f5f0a0a85571c2a6842b4d737232a46fba Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 15:53:16 +0800 Subject: [PATCH 05/16] =?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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index b2f55083d..ef1c1d78e 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -3,6 +3,7 @@ package repo import ( "fmt" "net/http" + "net/url" "strings" "time" @@ -114,7 +115,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { filename = sheetName + "_" + userName + "_" + strings.ReplaceAll(startDate, "-", "") + "_" + strings.ReplaceAll(endDate, "-", "") + ".xlsx" } - ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+filename) + 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()) From caec27cfe19a0d9618a0d2e26b3219e5bf4c77f6 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 16:02:57 +0800 Subject: [PATCH 06/16] =?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 | 43 +++++++++++++++++++------------------- routers/repo/user_data_analysis.go | 5 +++++ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 25e6dcc2f..63b6a642d 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -7,7 +7,6 @@ import ( "time" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" "xorm.io/builder" ) @@ -183,7 +182,7 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus } statictisSess.OrderBy("count_date desc") - userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0, setting.UI.IssuePagingNum) + userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) if err := statictisSess.Table("user_business_analysis").Where(cond). Find(&userBusinessAnalysisList); err != nil { return nil, 0 @@ -191,27 +190,29 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus resultMap := make(map[int64]*UserBusinessAnalysis) - var newAndCond = builder.NewCond() - var newOrCond = builder.NewCond() - for _, userRecord := range userBusinessAnalysisList { - newOrCond.Or( - builder.Eq{"id": userRecord.ID}, + if opts.Page >= 0 && opts.PageSize > 0 { + var newAndCond = builder.NewCond() + var newOrCond = builder.NewCond() + for _, userRecord := range userBusinessAnalysisList { + newOrCond.Or( + builder.Eq{"id": userRecord.ID}, + ) + } + newAndCond = newAndCond.And( + newOrCond, + ) + newAndCond = newAndCond.And( + builder.Gte{"count_date": fmt.Sprint(opts.StartTime)}, + ) + newAndCond = newAndCond.And( + builder.Lte{"count_date": fmt.Sprint(opts.EndTime)}, ) - } - newAndCond = newAndCond.And( - newOrCond, - ) - newAndCond = newAndCond.And( - builder.Gte{"count_date": fmt.Sprint(opts.StartTime)}, - ) - newAndCond = newAndCond.And( - builder.Lte{"count_date": fmt.Sprint(opts.EndTime)}, - ) - userBusinessAnalysisList = make([]*UserBusinessAnalysis, 0) - if err := statictisSess.Table("user_business_analysis").Where(newAndCond). - Find(&userBusinessAnalysisList); err != nil { - return nil, 0 + userBusinessAnalysisList = make([]*UserBusinessAnalysis, 0) + if err := statictisSess.Table("user_business_analysis").Where(newAndCond). + Find(&userBusinessAnalysisList); err != nil { + return nil, 0 + } } log.Info("query result size=" + fmt.Sprint(len(userBusinessAnalysisList))) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index ef1c1d78e..6a0d3e8bb 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -46,6 +46,11 @@ func QueryUserStaticDataPage(ctx *context.Context) { endTime = endTime.AddDate(0, 0, 1) log.Info("startTime=" + fmt.Sprint(startTime.Unix()) + " endDate=" + fmt.Sprint(endTime.Unix())) + if IsReturnFile { + page = -1 + pageSize = -1 + } + pageOpts := &models.UserBusinessAnalysisQueryOptions{ ListOptions: models.ListOptions{ Page: page, From 43733e2e690a8111c27f86741c1e4d48baa6741c Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 16:14:48 +0800 Subject: [PATCH 07/16] =?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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index c8f169887..54af36e60 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -28,7 +28,8 @@ - 下载报告 + + 下载报告 From 98148b1d860c678d548b9803798b19031b19afda Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 16:18:13 +0800 Subject: [PATCH 08/16] =?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 | 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 54af36e60..68e74ab10 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -29,7 +29,7 @@ - 下载报告 + 下载报告 From d68f09029a89d4d92887eb2df2679df95b6e7304 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 16:22:57 +0800 Subject: [PATCH 09/16] =?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 +- web_src/js/components/UserAnalysis.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 6a0d3e8bb..4a63bf509 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -67,7 +67,7 @@ func QueryUserStaticDataPage(ctx *context.Context) { if IsReturnFile { //writer exec file. xlsx := excelize.NewFile() - sheetName := ctx.Tr("static.sheetname") + sheetName := ctx.Tr("user.static.sheetname") index := xlsx.NewSheet(sheetName) dataHeader := map[string]string{ "A1": ctx.Tr("user.static.id"), diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 68e74ab10..0477dc874 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -29,7 +29,7 @@ - 下载报告 + 下载报告 From bb5fae78e376afc08bd80f04a61b595aa4e6a937 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 16:29:17 +0800 Subject: [PATCH 10/16] =?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 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 63b6a642d..b3f548156 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -159,10 +159,10 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus ) } cond = cond.And( - builder.Gte{"count_date": fmt.Sprint(pageStartTime)}, + builder.Gte{"count_date": pageStartTime.Unix()}, ) cond = cond.And( - builder.Lte{"count_date": fmt.Sprint(pageEndTime)}, + builder.Lte{"count_date": pageEndTime.Unix()}, ) count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) @@ -202,10 +202,10 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus newOrCond, ) newAndCond = newAndCond.And( - builder.Gte{"count_date": fmt.Sprint(opts.StartTime)}, + builder.Gte{"count_date": opts.StartTime}, ) newAndCond = newAndCond.And( - builder.Lte{"count_date": fmt.Sprint(opts.EndTime)}, + builder.Lte{"count_date": opts.EndTime}, ) userBusinessAnalysisList = make([]*UserBusinessAnalysis, 0) From 900f664da5b83d6e973eaeef0df6ed1defb2f16d Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 16:37:54 +0800 Subject: [PATCH 11/16] =?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 --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + routers/repo/user_data_analysis.go | 54 ++++++++++++++++++---------------- web_src/js/components/UserAnalysis.vue | 2 +- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index d1ce19c79..cac2153bb 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -406,6 +406,7 @@ static.sheetname=User Analysis static.id=ID static.name=User Name static.codemergecount=PR Count +static.commitcount=Commit Count static.issuecount=Issue Count static.commentcount=Comment Count static.focusrepocount=Focus Repo Count diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 47b900e93..9918d47e0 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -409,6 +409,7 @@ static.sheetname=用户分析 static.id=ID static.name=用户名 static.codemergecount=PR数 +static.commitcount=commit次数 static.issuecount=提出任务数 static.commentcount=评论数 static.focusrepocount=关注项目数 diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 4a63bf509..134896177 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -73,19 +73,20 @@ func QueryUserStaticDataPage(ctx *context.Context) { "A1": ctx.Tr("user.static.id"), "B1": ctx.Tr("user.static.name"), "C1": ctx.Tr("user.static.codemergecount"), - "D1": ctx.Tr("user.static.issuecount"), - "E1": ctx.Tr("user.static.commentcount"), - "F1": ctx.Tr("user.static.focusrepocount"), - "G1": ctx.Tr("user.static.starrepocount"), - "H1": ctx.Tr("user.static.logincount"), - "I1": ctx.Tr("user.static.watchedcount"), - "J1": ctx.Tr("user.static.commitcodesize"), - "K1": ctx.Tr("user.static.solveissuecount"), - "L1": ctx.Tr("user.static.encyclopediascount"), - "M1": ctx.Tr("user.static.createrepocount"), - "N1": ctx.Tr("user.static.openiindex"), - "O1": ctx.Tr("user.static.registdate"), - "P1": ctx.Tr("user.static.countdate"), + "D1": ctx.Tr("user.static.commitcount"), + "E1": ctx.Tr("user.static.issuecount"), + "F1": ctx.Tr("user.static.commentcount"), + "G1": ctx.Tr("user.static.focusrepocount"), + "H1": ctx.Tr("user.static.starrepocount"), + "I1": ctx.Tr("user.static.logincount"), + "J1": ctx.Tr("user.static.watchedcount"), + "K1": ctx.Tr("user.static.commitcodesize"), + "L1": ctx.Tr("user.static.solveissuecount"), + "M1": ctx.Tr("user.static.encyclopediascount"), + "N1": ctx.Tr("user.static.createrepocount"), + "O1": ctx.Tr("user.static.openiindex"), + "P1": ctx.Tr("user.static.registdate"), + "Q1": ctx.Tr("user.static.countdate"), } for k, v := range dataHeader { //设置单元格的值 @@ -98,19 +99,20 @@ func QueryUserStaticDataPage(ctx *context.Context) { xlsx.SetCellValue(sheetName, "A"+rows, userRecord.ID) xlsx.SetCellValue(sheetName, "B"+rows, userRecord.Name) xlsx.SetCellValue(sheetName, "C"+rows, userRecord.CodeMergeCount) - xlsx.SetCellValue(sheetName, "D"+rows, userRecord.IssueCount) - xlsx.SetCellValue(sheetName, "E"+rows, userRecord.CommentCount) - xlsx.SetCellValue(sheetName, "F"+rows, userRecord.FocusRepoCount) - xlsx.SetCellValue(sheetName, "G"+rows, userRecord.StarRepoCount) - xlsx.SetCellValue(sheetName, "H"+rows, userRecord.LoginCount) - xlsx.SetCellValue(sheetName, "I"+rows, userRecord.WatchedCount) - xlsx.SetCellValue(sheetName, "J"+rows, userRecord.CommitCodeSize) - xlsx.SetCellValue(sheetName, "K"+rows, userRecord.SolveIssueCount) - xlsx.SetCellValue(sheetName, "L"+rows, userRecord.EncyclopediasCount) - xlsx.SetCellValue(sheetName, "M"+rows, userRecord.CreateRepoCount) - xlsx.SetCellValue(sheetName, "N"+rows, userRecord.OpenIIndex) - xlsx.SetCellValue(sheetName, "O"+rows, userRecord.RegistDate.Format("2006-01-02")) - xlsx.SetCellValue(sheetName, "P"+rows, time.Unix(userRecord.CountDate, 0).Format("2006-01-02")) + xlsx.SetCellValue(sheetName, "D"+rows, userRecord.CommitCount) + xlsx.SetCellValue(sheetName, "E"+rows, userRecord.IssueCount) + xlsx.SetCellValue(sheetName, "F"+rows, userRecord.CommentCount) + xlsx.SetCellValue(sheetName, "G"+rows, userRecord.FocusRepoCount) + xlsx.SetCellValue(sheetName, "H"+rows, userRecord.StarRepoCount) + xlsx.SetCellValue(sheetName, "I"+rows, userRecord.LoginCount) + xlsx.SetCellValue(sheetName, "J"+rows, userRecord.WatchedCount) + xlsx.SetCellValue(sheetName, "K"+rows, userRecord.CommitCodeSize) + 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, "P"+rows, userRecord.RegistDate.Format("2006-01-02")) + xlsx.SetCellValue(sheetName, "Q"+rows, time.Unix(userRecord.CountDate, 0).Format("2006-01-02")) } //设置默认打开的表单 diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 0477dc874..609306201 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -29,7 +29,7 @@ - 下载报告 + 下载报告 From c2ee4a01bf38e6fd8b0304149c344cfa5a17e650 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 16:42:49 +0800 Subject: [PATCH 12/16] =?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 | 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 609306201..7774c7219 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -29,7 +29,7 @@ - 下载报告 + 下载报告 From 926151239cb2024940e49fe32136019b63dba93d Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 17:13:51 +0800 Subject: [PATCH 13/16] =?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 b3f548156..c16721dd9 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -194,7 +194,7 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus var newAndCond = builder.NewCond() var newOrCond = builder.NewCond() for _, userRecord := range userBusinessAnalysisList { - newOrCond.Or( + newOrCond = newOrCond.Or( builder.Eq{"id": userRecord.ID}, ) } @@ -267,7 +267,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, 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, currentTimeNow.Location()) } DataDate := startTime.Format("2006-01-02") From d2500b131ec34de3be659114f6e3dd42dc96d631 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 17:20:57 +0800 Subject: [PATCH 14/16] =?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 | 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 7774c7219..c2b87858e 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -29,7 +29,7 @@ - 下载报告 + 下载报告 From 35868b0aa5c7de61d8f0d64f6ce4e3faf085d690 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 17:31:40 +0800 Subject: [PATCH 15/16] =?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 c16721dd9..19a24dbac 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -22,7 +22,7 @@ type UserBusinessAnalysis struct { //action :ActionCommitRepo // 5 CommitCount int `xorm:"NOT NULL DEFAULT 0"` - //action :ActionCommentIssue // 10 + //action :ActionCreateIssue // 10 IssueCount int `xorm:"NOT NULL DEFAULT 0"` //comment table current date @@ -273,7 +273,7 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time, DataDate := startTime.Format("2006-01-02") CodeMergeCountMap := queryPullRequest(start_unix, end_unix) CommitCountMap := queryAction(start_unix, end_unix, 5) - IssueCountMap := queryAction(start_unix, end_unix, 10) + IssueCountMap := queryAction(start_unix, end_unix, 6) CommentCountMap := queryComment(start_unix, end_unix) FocusRepoCountMap := queryWatch(start_unix, end_unix) From 742af70978ef0627f0b3fef638539e1cd63367eb Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 16 Nov 2021 17:35:41 +0800 Subject: [PATCH 16/16] =?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 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index c2b87858e..c8f169887 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -28,8 +28,7 @@ - - 下载报告 + 下载报告