Browse Source

Merge remote-tracking branch 'origin/V20211115' into zouap

pull/1036/head
zouap 3 years ago
parent
commit
ffd715c2df
4 changed files with 23 additions and 1 deletions
  1. +7
    -0
      models/repo_statistic.go
  2. +1
    -1
      modules/setting/setting.go
  3. +2
    -0
      routers/api/v1/api.go
  4. +13
    -0
      routers/api/v1/repo/repo_dashbord.go

+ 7
- 0
models/repo_statistic.go View File

@@ -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=?"




+ 1
- 1
modules/setting/setting.go View File

@@ -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")


} }




+ 2
- 0
routers/api/v1/api.go View File

@@ -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() {


+ 13
- 0
routers/api/v1/repo/repo_dashbord.go View File

@@ -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()


Loading…
Cancel
Save