aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-10-11 06:41:39 +0000
committerGitHub <noreply@github.com>2022-10-11 07:41:39 +0100
commitc540ee08d322c5de41c014330434351fbd885d74 (patch)
tree2501c7d4bccc4a8c8f86d5e21b26b0b2937c6121 /models
parentb59b0cad0a550223f74add109ff13c0d2f4309f3 (diff)
downloadgitea-c540ee08d322c5de41c014330434351fbd885d74.tar.gz
gitea-c540ee08d322c5de41c014330434351fbd885d74.zip
Add Num{Issues,Pulls} stats checks (#21404)
- Currently `repository.Num{Issues,Pulls}` weren't checked and could become out-of-consistency. Adds these two checks to `CheckRepoStats`. - Fix incorrect SQL query for `repository.NumClosedPulls`, the check should be for `repo_num_pulls`. - Reference: https://codeberg.org/Codeberg/Community/issues/696
Diffstat (limited to 'models')
-rw-r--r--models/repo.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go
index f2676a5696..558678bfe5 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -438,15 +438,27 @@ func CheckRepoStats(ctx context.Context) error {
repoStatsCorrectNumStars,
"repository count 'num_stars'",
},
+ // Repository.NumIssues
+ {
+ statsQuery("SELECT repo.id FROM `repository` repo WHERE repo.num_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", false, false),
+ repoStatsCorrectNumIssues,
+ "repository count 'num_issues'",
+ },
// Repository.NumClosedIssues
{
statsQuery("SELECT repo.id FROM `repository` repo WHERE repo.num_closed_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", true, false),
repoStatsCorrectNumClosedIssues,
"repository count 'num_closed_issues'",
},
+ // Repository.NumPulls
+ {
+ statsQuery("SELECT repo.id FROM `repository` repo WHERE repo.num_pulls!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", false, true),
+ repoStatsCorrectNumPulls,
+ "repository count 'num_pulls'",
+ },
// Repository.NumClosedPulls
{
- statsQuery("SELECT repo.id FROM `repository` repo WHERE repo.num_closed_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", true, true),
+ statsQuery("SELECT repo.id FROM `repository` repo WHERE repo.num_closed_pulls!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", true, true),
repoStatsCorrectNumClosedPulls,
"repository count 'num_closed_pulls'",
},