summaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/models/issue.go b/models/issue.go
index 340a431ad1..03af32700d 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -76,6 +76,7 @@ var (
const issueTasksRegexpStr = `(^\s*[-*]\s\[[\sx]\]\s.)|(\n\s*[-*]\s\[[\sx]\]\s.)`
const issueTasksDoneRegexpStr = `(^\s*[-*]\s\[[x]\]\s.)|(\n\s*[-*]\s\[[x]\]\s.)`
const issueMaxDupIndexAttempts = 3
+const maxIssueIDs = 950
func init() {
issueTasksPat = regexp.MustCompile(issueTasksRegexpStr)
@@ -1098,6 +1099,9 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) {
}
if len(opts.IssueIDs) > 0 {
+ if len(opts.IssueIDs) > maxIssueIDs {
+ opts.IssueIDs = opts.IssueIDs[:maxIssueIDs]
+ }
sess.In("issue.id", opts.IssueIDs)
}
@@ -1176,6 +1180,26 @@ func CountIssuesByRepo(opts *IssuesOptions) (map[int64]int64, error) {
return countMap, nil
}
+// GetRepoIDsForIssuesOptions find all repo ids for the given options
+func GetRepoIDsForIssuesOptions(opts *IssuesOptions, user *User) ([]int64, error) {
+ repoIDs := make([]int64, 0, 5)
+ sess := x.NewSession()
+ defer sess.Close()
+
+ opts.setupSession(sess)
+
+ accessCond := accessibleRepositoryCondition(user)
+ if err := sess.Where(accessCond).
+ Join("INNER", "repository", "`issue`.repo_id = `repository`.id").
+ Distinct("issue.repo_id").
+ Table("issue").
+ Find(&repoIDs); err != nil {
+ return nil, err
+ }
+
+ return repoIDs, nil
+}
+
// Issues returns a list of issues by given conditions.
func Issues(opts *IssuesOptions) ([]*Issue, error) {
sess := x.NewSession()
@@ -1313,6 +1337,9 @@ func getIssueStatsChunk(opts *IssueStatsOptions, issueIDs []int64) (*IssueStats,
Where("issue.repo_id = ?", opts.RepoID)
if len(opts.IssueIDs) > 0 {
+ if len(opts.IssueIDs) > maxIssueIDs {
+ opts.IssueIDs = opts.IssueIDs[:maxIssueIDs]
+ }
sess.In("issue.id", opts.IssueIDs)
}
@@ -1382,6 +1409,7 @@ type UserIssueStatsOptions struct {
FilterMode int
IsPull bool
IsClosed bool
+ IssueIDs []int64
}
// GetUserIssueStats returns issue statistic information for dashboard by given conditions.
@@ -1394,6 +1422,12 @@ func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error) {
if len(opts.RepoIDs) > 0 {
cond = cond.And(builder.In("issue.repo_id", opts.RepoIDs))
}
+ if len(opts.IssueIDs) > 0 {
+ if len(opts.IssueIDs) > maxIssueIDs {
+ opts.IssueIDs = opts.IssueIDs[:maxIssueIDs]
+ }
+ cond = cond.And(builder.In("issue.id", opts.IssueIDs))
+ }
switch opts.FilterMode {
case FilterModeAll: