aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-06-16 04:51:34 +0200
committerGitHub <noreply@github.com>2022-06-16 10:51:34 +0800
commit7d1770cd714416bd80f114681d19e3076a0b0966 (patch)
tree301899eadd622de920b6f46ca636913616bfcf48 /models
parent6473bd333a54f38f333920a6e567edafe6692ff5 (diff)
downloadgitea-7d1770cd714416bd80f114681d19e3076a0b0966.tar.gz
gitea-7d1770cd714416bd80f114681d19e3076a0b0966.zip
Use correct count for `NumOpenIssues` (#19980)
- Don't specify the field in `Count` instead use `Cols` for this. - Call `log.Error` when a error occur. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models')
-rw-r--r--models/project/issue.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/models/project/issue.go b/models/project/issue.go
index 04efc0e749..6e6a8c5746 100644
--- a/models/project/issue.go
+++ b/models/project/issue.go
@@ -9,6 +9,7 @@ import (
"fmt"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/modules/log"
)
// ProjectIssue saves relation from issue to a project
@@ -41,6 +42,7 @@ func (p *Project) NumIssues() int {
Cols("issue_id").
Count()
if err != nil {
+ log.Error("NumIssues: %v", err)
return 0
}
return int(c)
@@ -54,6 +56,7 @@ func (p *Project) NumClosedIssues() int {
Cols("issue_id").
Count()
if err != nil {
+ log.Error("NumClosedIssues: %v", err)
return 0
}
return int(c)
@@ -63,8 +66,11 @@ func (p *Project) NumClosedIssues() int {
func (p *Project) NumOpenIssues() int {
c, err := db.GetEngine(db.DefaultContext).Table("project_issue").
Join("INNER", "issue", "project_issue.issue_id=issue.id").
- Where("project_issue.project_id=? AND issue.is_closed=?", p.ID, false).Count("issue.id")
+ Where("project_issue.project_id=? AND issue.is_closed=?", p.ID, false).
+ Cols("issue_id").
+ Count()
if err != nil {
+ log.Error("NumOpenIssues: %v", err)
return 0
}
return int(c)