diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-04-25 15:04:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 15:04:42 +0800 |
commit | fc002860d8fee23ce6fe018e81c449398d9c51c0 (patch) | |
tree | 2995d60f0a616d998cfd8b748bfa64a99e7267b8 /models | |
parent | 2ec2baf24894727febb964039b69982e7ed3c633 (diff) | |
download | gitea-fc002860d8fee23ce6fe018e81c449398d9c51c0.tar.gz gitea-fc002860d8fee23ce6fe018e81c449398d9c51c0.zip |
Simplify the code to get issue count (#19380)
* Simple the code to get issue count
* Improve codes
Diffstat (limited to 'models')
-rw-r--r-- | models/issue.go | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/models/issue.go b/models/issue.go index b1fa2d02ad..68582b2b14 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1510,20 +1510,10 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { func CountIssues(opts *IssuesOptions) (int64, error) { e := db.GetEngine(db.DefaultContext) - countsSlice := make([]*struct { - Count int64 - }, 0, 1) - sess := e.Select("COUNT(issue.id) AS count").Table("issue") sess.Join("INNER", "repository", "`issue`.repo_id = `repository`.id") opts.setupSessionNoLimit(sess) - if err := sess.Find(&countsSlice); err != nil { - return 0, fmt.Errorf("unable to CountIssues: %w", err) - } - if len(countsSlice) != 1 { - return 0, fmt.Errorf("unable to get one row result when CountIssues, row count=%d", len(countsSlice)) - } - return countsSlice[0].Count, nil + return sess.Count() } // GetParticipantsIDsByIssueID returns the IDs of all users who participated in comments of an issue, |