From 43200e0e67263a537b7e56d4214ee9408006a418 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 10 Nov 2021 14:57:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E5=8D=87=E7=BA=A7=E5=90=8E=E6=81=A2=E5=A4=8Dfork?= =?UTF-8?q?=E6=8C=87=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/repo_statistic.go | 7 +++++++ routers/api/v1/api.go | 2 ++ routers/api/v1/repo/repo_dashbord.go | 13 +++++++++++++ 3 files changed, 22 insertions(+) diff --git a/models/repo_statistic.go b/models/repo_statistic.go index 9184ab4ec..df065bb79 100755 --- a/models/repo_statistic.go +++ b/models/repo_statistic.go @@ -158,6 +158,13 @@ func InsertRepoStat(repoStat *RepoStatistic) (int64, error) { return xStatistic.Insert(repoStat) } +func RestoreRepoStatFork(numForks int64, repoId int64) error { + sql := "update repo_statistic set num_forks=? where repo_id=?" + + _, err := xStatistic.Exec(sql, numForks, repoId) + return err +} + func UpdateRepoStat(repoStat *RepoStatistic) error { sql := "update repo_statistic set impact=?,completeness=?,liveness=?,project_health=?,team_health=?,growth=?,radar_total=? where repo_id=? and date=?" diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index dd744e933..8b068d612 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -527,6 +527,8 @@ func RegisterRoutes(m *macaron.Macaron) { //Project board m.Group("/projectboard", func() { + m.Get("/restoreFork", adminReq, repo.RestoreForkNumber) + m.Group("/project", func() { m.Get("", adminReq, repo.GetAllProjectsPeriodStatistics) m.Group("/:id", func() { diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index 6759470fb..e48bda50d 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -50,6 +50,19 @@ type ProjectLatestData struct { Top10 []UserInfo `json:"top10"` } +func RestoreForkNumber(ctx *context.Context) { + repos, err := models.GetAllRepositories() + if err != nil { + log.Error("GetAllRepositories failed: %v", err.Error()) + return + } + for _, repo := range repos { + models.RestoreRepoStatFork(int64(repo.NumForks), repo.ID) + } + + ctx.JSON(http.StatusOK, struct{}{}) +} + func GetAllProjectsPeriodStatistics(ctx *context.Context) { recordBeginTime, err := getRecordBeginTime() From 7dd86b5e245a81ef57da87d6e3ee791befab9864 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 10 Nov 2021 15:00:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=9C=8B=E6=9D=BF?= =?UTF-8?q?=E8=B5=B7=E5=A7=8B=E6=97=B6=E9=97=B4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/setting/setting.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index abe406de8..738284c8e 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -1325,7 +1325,7 @@ func SetRadarMapConfig() { RadarMap.GrowthContributors = sec.Key("growth_contributors").MustFloat64(0.2) 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-04") + RadarMap.RecordBeginTime = sec.Key("record_beigin_time").MustString("2021-11-05") }