@@ -158,6 +158,13 @@ func InsertRepoStat(repoStat *RepoStatistic) (int64, error) { | |||||
return xStatistic.Insert(repoStat) | 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 { | 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=?" | sql := "update repo_statistic set impact=?,completeness=?,liveness=?,project_health=?,team_health=?,growth=?,radar_total=? where repo_id=? and date=?" | ||||
@@ -1325,7 +1325,7 @@ func SetRadarMapConfig() { | |||||
RadarMap.GrowthContributors = sec.Key("growth_contributors").MustFloat64(0.2) | RadarMap.GrowthContributors = sec.Key("growth_contributors").MustFloat64(0.2) | ||||
RadarMap.GrowthCommit = sec.Key("growth_commit").MustFloat64(0.2) | RadarMap.GrowthCommit = sec.Key("growth_commit").MustFloat64(0.2) | ||||
RadarMap.GrowthComments = sec.Key("growth_comments").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") | |||||
} | } | ||||
@@ -527,6 +527,8 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
//Project board | //Project board | ||||
m.Group("/projectboard", func() { | m.Group("/projectboard", func() { | ||||
m.Get("/restoreFork", adminReq, repo.RestoreForkNumber) | |||||
m.Group("/project", func() { | m.Group("/project", func() { | ||||
m.Get("", adminReq, repo.GetAllProjectsPeriodStatistics) | m.Get("", adminReq, repo.GetAllProjectsPeriodStatistics) | ||||
m.Group("/:id", func() { | m.Group("/:id", func() { | ||||
@@ -50,6 +50,19 @@ type ProjectLatestData struct { | |||||
Top10 []UserInfo `json:"top10"` | 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) { | func GetAllProjectsPeriodStatistics(ctx *context.Context) { | ||||
recordBeginTime, err := getRecordBeginTime() | recordBeginTime, err := getRecordBeginTime() | ||||