diff options
author | Aravinth Manivannan <realaravinth@batsense.net> | 2022-01-17 18:31:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-17 19:31:58 +0100 |
commit | 076cead40dd4cd498a70f4bd09b0f0077b26144e (patch) | |
tree | d9988cf0d537ac2ce6d95c2a88bf2f4c0feb303c /models/issue_milestone_test.go | |
parent | 7dde39a6dba6c0d7468e1d5159b376f86b9ca729 (diff) | |
download | gitea-076cead40dd4cd498a70f4bd09b0f0077b26144e.tar.gz gitea-076cead40dd4cd498a70f4bd09b0f0077b26144e.zip |
Fix CheckRepoStats and reuse it during migration (#18264)
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)
Diffstat (limited to 'models/issue_milestone_test.go')
-rw-r--r-- | models/issue_milestone_test.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/models/issue_milestone_test.go b/models/issue_milestone_test.go index 9b40144e65..6593f78fa1 100644 --- a/models/issue_milestone_test.go +++ b/models/issue_milestone_test.go @@ -228,14 +228,14 @@ func TestUpdateMilestoneCounters(t *testing.T) { issue.ClosedUnix = timeutil.TimeStampNow() _, err := db.GetEngine(db.DefaultContext).ID(issue.ID).Cols("is_closed", "closed_unix").Update(issue) assert.NoError(t, err) - assert.NoError(t, updateMilestoneCounters(db.GetEngine(db.DefaultContext), issue.MilestoneID)) + assert.NoError(t, updateMilestoneCounters(db.DefaultContext, issue.MilestoneID)) unittest.CheckConsistencyFor(t, &Milestone{}) issue.IsClosed = false issue.ClosedUnix = 0 _, err = db.GetEngine(db.DefaultContext).ID(issue.ID).Cols("is_closed", "closed_unix").Update(issue) assert.NoError(t, err) - assert.NoError(t, updateMilestoneCounters(db.GetEngine(db.DefaultContext), issue.MilestoneID)) + assert.NoError(t, updateMilestoneCounters(db.DefaultContext, issue.MilestoneID)) unittest.CheckConsistencyFor(t, &Milestone{}) } |