summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-10-25 20:47:46 +0800
committerGitHub <noreply@github.com>2022-10-25 14:47:46 +0200
commit5e8e3ecbeb71ea924ed9662251af2897285b8220 (patch)
tree7e75b1d76fc496c117ee2e8f6712804822320e64 /models/repo.go
parent29c00eb1ed13fbcd2a5e493d075c2bbd0e2a26f7 (diff)
downloadgitea-5e8e3ecbeb71ea924ed9662251af2897285b8220.tar.gz
gitea-5e8e3ecbeb71ea924ed9662251af2897285b8220.zip
Fix issues count bug (#21557)
fix #19349 , #19505 Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/models/repo.go b/models/repo.go
index b544853a5d..569dafee5f 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -404,24 +404,19 @@ func repoStatsCorrectIssueNumComments(ctx context.Context, id int64) error {
}
func repoStatsCorrectNumIssues(ctx context.Context, id int64) error {
- return repoStatsCorrectNum(ctx, id, false, "num_issues")
+ return repo_model.UpdateRepoIssueNumbers(ctx, id, false, false)
}
func repoStatsCorrectNumPulls(ctx context.Context, id int64) error {
- return repoStatsCorrectNum(ctx, id, true, "num_pulls")
-}
-
-func repoStatsCorrectNum(ctx context.Context, id int64, isPull bool, field string) error {
- _, err := db.GetEngine(ctx).Exec("UPDATE `repository` SET "+field+"=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_pull=?) WHERE id=?", id, isPull, id)
- return err
+ return repo_model.UpdateRepoIssueNumbers(ctx, id, true, false)
}
func repoStatsCorrectNumClosedIssues(ctx context.Context, id int64) error {
- return repo_model.StatsCorrectNumClosed(ctx, id, false, "num_closed_issues")
+ return repo_model.UpdateRepoIssueNumbers(ctx, id, false, true)
}
func repoStatsCorrectNumClosedPulls(ctx context.Context, id int64) error {
- return repo_model.StatsCorrectNumClosed(ctx, id, true, "num_closed_pulls")
+ return repo_model.UpdateRepoIssueNumbers(ctx, id, true, true)
}
func statsQuery(args ...interface{}) func(context.Context) ([]map[string][]byte, error) {