From 076cead40dd4cd498a70f4bd09b0f0077b26144e Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Mon, 17 Jan 2022 18:31:58 +0000 Subject: Fix CheckRepoStats and reuse it during migration (#18264) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CheckRepoStats function missed the following counters: - label num_closed_issues & num_closed_pulls - milestone num_closed_issues & num_closed_pulls The update SQL statements for updating the repository num_closed_issues & num_closed_pulls fields were repeated in three functions (repo.CheckRepoStats, migrate.insertIssues and models.Issue.updateClosedNum) and were moved to a single helper. The UpdateRepoStats is implemented and called in the Finish migration method so that it happens immediately instead of wating for the CheckRepoStats to run. Signed-off-by: Loïc Dachary loic@dachary.org --- [source](https://lab.forgefriends.org/forgefriends/forgefriends/-/merge_requests/34) --- services/migrations/gitea_uploader.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'services') diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index 79225d75a0..035ca2e5a2 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -978,6 +978,10 @@ func (g *GiteaLocalUploader) Finish() error { return err } + if err := models.UpdateRepoStats(db.DefaultContext, g.repo.ID); err != nil { + return err + } + g.repo.Status = repo_model.RepositoryReady return repo_model.UpdateRepositoryCols(g.repo, "status") } -- cgit v1.2.3