From 6f17baaf69afca92e070af21cda38824228e80f9 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Fri, 12 Nov 2021 17:43:37 +0800 Subject: [PATCH 01/44] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D=E6=8C=89?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=AE=9A=E4=B9=89=E5=B9=B6=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E4=B9=B1=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/api/v1/repo/repo_dashbord.go | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index d5d4ceae2..0fcd70a99 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "net/http" + "net/url" "os" "path" "strconv" @@ -169,7 +170,7 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) { return } - fileName := getFileName(ctx, beginTime, endTime) + fileName, frontName := getFileName(ctx, beginTime, endTime) 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()) @@ -197,20 +198,24 @@ func ServeAllProjectsPeriodStatisticsFile(ctx *context.Context) { } - ctx.ServeFile(fileName) + ctx.ServeFile(fileName, url.QueryEscape(frontName)) } -func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time) string { - baseName := setting.RadarMap.Path + "/" - if ctx.QueryTrim("type") != "" { - baseName = baseName + ctx.QueryTrim("type") + "_" - } +func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time) (string, string) { + baseName := setting.RadarMap.Path + "/项目分析_" + if ctx.QueryTrim("q") != "" { baseName = baseName + ctx.QueryTrim("q") + "_" } - baseName = baseName + beginTime.AddDate(0, 0, -1).Format(DATE_FORMAT) + "_to_" + endTime.AddDate(0, 0, -1).Format(DATE_FORMAT) + "_" + strconv.FormatInt(time.Now().Unix(), 10) + ".csv" - return baseName + if ctx.QueryTrim("type") == "all" { + baseName = baseName + "所有" + } else { + baseName = baseName + beginTime.AddDate(0, 0, -1).Format(DATE_FORMAT) + "_" + endTime.AddDate(0, 0, -1).Format(DATE_FORMAT) + } + frontName := baseName + ".csv" + localName := baseName + "_" + strconv.FormatInt(time.Now().Unix(), 10) + ".csv" + return localName, path.Base(frontName) } func ClearUnusedStatisticsFile() { @@ -230,8 +235,8 @@ func ClearUnusedStatisticsFile() { func allProjectsPeroidHeader(ctx *context.Context) []string { - return []string{ctx.Tr("repos.id"), ctx.Tr("repos.projectName"), ctx.Tr("repos.isPrivate"), ctx.Tr("repos.openi"), ctx.Tr("repos.visit"), ctx.Tr("repos.download"), ctx.Tr("repos.pr"), ctx.Tr("repos.commit"), - ctx.Tr("repos.watches"), ctx.Tr("repos.stars"), ctx.Tr("repos.forks"), ctx.Tr("repos.issues"), ctx.Tr("repos.closedIssues"), ctx.Tr("repos.contributor")} + return []string{ctx.Tr("admin.repos.id"), ctx.Tr("admin.repos.projectName"), ctx.Tr("admin.repos.isPrivate"), ctx.Tr("admin.repos.openi"), ctx.Tr("admin.repos.visit"), ctx.Tr("admin.repos.download"), ctx.Tr("admin.repos.pr"), ctx.Tr("admin.repos.commit"), + ctx.Tr("admin.repos.watches"), ctx.Tr("admin.repos.stars"), ctx.Tr("admin.repos.forks"), ctx.Tr("admin.repos.issues"), ctx.Tr("admin.repos.closedIssues"), ctx.Tr("admin.repos.contributor")} } @@ -245,9 +250,9 @@ func allProjectsPeroidValues(rs *models.RepoStatistic, ctx *context.Context) []s func getIsPrivateDisplay(private bool, ctx *context.Context) string { if private { - return ctx.Tr("repos.yes") + return ctx.Tr("admin.repos.yes") } else { - return ctx.Tr("repos.no") + return ctx.Tr("admin.repos.no") } } From 0c7a51c60ca013a5f4d126646cccf358d17e0387 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 15 Nov 2021 09:48:11 +0800 Subject: [PATCH 02/44] =?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 77b569af2..a4a155ba7 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -231,7 +231,7 @@ func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime ti log.Info("start to count other user info data") sess := x.NewSession() defer sess.Close() - sess.Select("`user`.*").Table("user").Where("type=1 and is_active=true") + sess.Select("`user`.*").Table("user").Where("type != 1 and is_active=true") userList := make([]*User, 0) sess.Find(&userList) From 170c3be87d1b4451ea045f382880d46d0e093063 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 15 Nov 2021 10:18:31 +0800 Subject: [PATCH 03/44] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=8D=87=E7=BA=A7=E5=8C=BA=E5=88=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/custom_migrations.go | 13 +++++++++++++ models/models.go | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/models/custom_migrations.go b/models/custom_migrations.go index b196c5a8b..0b9a0d552 100644 --- a/models/custom_migrations.go +++ b/models/custom_migrations.go @@ -14,6 +14,8 @@ var customMigrations = []CustomMigration{ {"Custom v1 Topic struct change to support chinese", syncTopicStruct}, } +var customMigrationsStatic = []CustomMigration{} + func MigrateCustom(x *xorm.Engine) { for _, m := range customMigrations { @@ -27,6 +29,17 @@ func MigrateCustom(x *xorm.Engine) { } +func MigrateCustomStatic(x *xorm.Engine) { + for _, m := range customMigrationsStatic { + log.Info("Migration: %s", m.Description) + if err := m.Migrate(x); err != nil { + + log.Error("Migration: %v", err) + + } + } +} + func syncTopicStruct(x *xorm.Engine) error { query := "ALTER TABLE topic ALTER COLUMN name TYPE varchar(105);" diff --git a/models/models.go b/models/models.go index 696d0949b..ad027cd24 100755 --- a/models/models.go +++ b/models/models.go @@ -190,7 +190,7 @@ func setEngine(engine *xorm.Engine, table []interface{}, database *setting.DBInf engine.SetMaxIdleConns(setting.Database.MaxIdleConns) engine.SetConnMaxLifetime(setting.Database.ConnMaxLifetime) engine.Sync2(table...) - MigrateCustom(engine) + return nil } @@ -202,6 +202,7 @@ func SetEngine() (err error) { if err = setEngine(x, tables, setting.Database); err != nil { return err } + MigrateCustom(x) xStatistic, err = getEngine(setting.DatabaseStatistic) if err != nil { @@ -210,7 +211,7 @@ func SetEngine() (err error) { if err = setEngine(xStatistic, tablesStatistic, setting.DatabaseStatistic); err != nil { return err } - + MigrateCustomStatic(xStatistic) return nil } From 5fc28bc6b985f10d7c6bec342d6fd35195471efa Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Mon, 15 Nov 2021 10:36:23 +0800 Subject: [PATCH 04/44] fix chinese fileName bug --- modules/storage/obs.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/storage/obs.go b/modules/storage/obs.go index 239580adb..c25787703 100755 --- a/modules/storage/obs.go +++ b/modules/storage/obs.go @@ -6,6 +6,7 @@ package storage import ( "io" + "net/url" "path" "strconv" "strings" @@ -262,6 +263,7 @@ func GetObsCreateSignedUrl(jobName, parentDir, fileName string) (string, error) input.Method = obs.HttpMethodGet reqParams := make(map[string]string) + fileName = url.QueryEscape(fileName) reqParams["response-content-disposition"] = "attachment; filename=\"" + fileName + "\"" input.QueryParams = reqParams output, err := ObsCli.CreateSignedUrl(input) From ba036592e8a27732e1cc8c15bd6b65b93be73e09 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 15 Nov 2021 10:58:51 +0800 Subject: [PATCH 05/44] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/models.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/models.go b/models/models.go index ad027cd24..86a091bca 100755 --- a/models/models.go +++ b/models/models.go @@ -202,7 +202,6 @@ func SetEngine() (err error) { if err = setEngine(x, tables, setting.Database); err != nil { return err } - MigrateCustom(x) xStatistic, err = getEngine(setting.DatabaseStatistic) if err != nil { @@ -211,7 +210,7 @@ func SetEngine() (err error) { if err = setEngine(xStatistic, tablesStatistic, setting.DatabaseStatistic); err != nil { return err } - MigrateCustomStatic(xStatistic) + return nil } @@ -223,7 +222,7 @@ func NewEngine(ctx context.Context, migrateFunc func(*xorm.Engine) error) (err e if err = newEngine(ctx, migrateFunc, x, tables, setting.Database); err != nil { return fmt.Errorf("newEngine failed: %v", err) } - + MigrateCustom(x) xStatistic, err = getEngine(setting.DatabaseStatistic) if err != nil { return fmt.Errorf("Failed to connect to database: %v", err) @@ -231,6 +230,7 @@ func NewEngine(ctx context.Context, migrateFunc func(*xorm.Engine) error) (err e if err = newEngine(ctx, migrateFunc, xStatistic, tablesStatistic, setting.DatabaseStatistic); err != nil { return fmt.Errorf("newEngine statistic failed: %v", err) } + MigrateCustomStatic(xStatistic) HasEngine = true From 82be794a01d54298676dc6468a08ea31a9048d23 Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 15 Nov 2021 14:15:33 +0800 Subject: [PATCH 06/44] modify code --- web_src/js/components/DataAnalysis.vue | 2 +- web_src/js/components/ProAnalysis.vue | 216 ++++++++++++++++++++++++++------- web_src/js/components/UserAnalysis.vue | 55 ++++++--- 3 files changed, 216 insertions(+), 57 deletions(-) diff --git a/web_src/js/components/DataAnalysis.vue b/web_src/js/components/DataAnalysis.vue index 8c632bccb..4c2657751 100755 --- a/web_src/js/components/DataAnalysis.vue +++ b/web_src/js/components/DataAnalysis.vue @@ -69,7 +69,7 @@ if(tab.name=="third"){ // document.getElementById('usr').style.display="block" // document.getElementById("pro").style.display='none' - //this.$refs.UserAnalysis.getUserList("all_usr",7) + this.$refs.UserAnalysis.getUserList("all_usr",7) this.isSecond = false this.isThird = true diff --git a/web_src/js/components/ProAnalysis.vue b/web_src/js/components/ProAnalysis.vue index 7df0854e5..8d4f25084 100755 --- a/web_src/js/components/ProAnalysis.vue +++ b/web_src/js/components/ProAnalysis.vue @@ -2,7 +2,7 @@
- 项目分析 数据更新时间:{{lastUpdatedTime}}/{{recordBeginTime}} + 项目分析 数据更新时间:{{lastUpdatedTime}} / 从{{recordBeginTime}}开始统计
@@ -30,8 +30,10 @@ + + @@ -152,28 +154,28 @@
- 项目创建时间
- {{tableDataIDTotal.creatTime}} + 项目创建时间 + {{tableDataIDTotal.creatTime}}
- OPenI指数
- {{tableDataIDTotal.openi | rounding}} + OpenI指数 + {{tableDataIDTotal.openi | rounding}}
- 评论数
- {{tableDataIDTotal.comment}} + 评论数 + {{tableDataIDTotal.comment}}
- 浏览数
- {{tableDataIDTotal.view}} + 浏览量 + {{tableDataIDTotal.view}}
- 代码下载量
- {{tableDataIDTotal.download}} + 代码下载量 + {{tableDataIDTotal.download}}
- 任务完成比例
- {{tableDataIDTotal.issueClosedRatio}} + 任务完成比例 + {{tableDataIDTotal.issueClosedRatio}}
@@ -213,8 +215,8 @@
- @@ -319,7 +321,7 @@ @@ -920,4 +1050,8 @@ height: 350px; width: 100%; } + .item_content{ + color: #409eff; + margin-top: 10px; + } \ No newline at end of file diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index 547a077f4..c8f169887 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -1,7 +1,7 @@