Browse Source

#3169

update
tags/v1.22.12.1^2
chenyifan01 3 years ago
parent
commit
2219f5aab4
2 changed files with 11 additions and 9 deletions
  1. +9
    -0
      models/repo.go
  2. +2
    -9
      routers/repo/repo_statistic.go

+ 9
- 0
models/repo.go View File

@@ -2972,3 +2972,12 @@ func OperateRepoModelNum(repoId int64, amount int64, engines ...*xorm.Engine) er
func OperateRepoAITaskNum(repoId int64, amount int64, engines ...*xorm.Engine) error {
return operateRepoCol(repoId, "ai_task_cnt", amount, engines...)
}

func UpdateRepositoryLastFourMonthCommits(repoID int64, amount int64) error {
_, err := x.Exec("update repository set last_four_month_commits = ? where id = ?", amount, repoID)
return err
}
func UpdateRepositoryLastMonthVisits(repoID int64, amount int64) error {
_, err := x.Exec("update repository set last_month_visits = ? where id = ?", amount, repoID)
return err
}

+ 2
- 9
routers/repo/repo_statistic.go View File

@@ -287,20 +287,13 @@ func RepoStatisticDaily(date string) {
}

func SyncStatDataToRepo(repo *models.Repository) {
changed := false
//Save the visit number of repository in the last month
if lv, err := models.SumLastMonthNumVisits(repo.ID); err == nil {
repo.LastMonthVisits = lv
changed = true
models.UpdateRepositoryLastMonthVisits(repo.ID, lv)
}
//Save the commits number of repository in the last four month
if lc, err := models.SumLastFourMonthNumCommits(repo.ID); err == nil {
repo.LastFourMonthCommits = lc
changed = true
}

if changed {
models.UpdateRepository(repo, false)
models.UpdateRepositoryLastFourMonthCommits(repo.ID, lc)
}
}



Loading…
Cancel
Save