|
|
@ -813,20 +813,19 @@ type IssuesOptions struct { |
|
|
|
SortType string |
|
|
|
SortType string |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Issues returns a list of issues by given conditions.
|
|
|
|
func buildIssuesQuery(opts *IssuesOptions) *xorm.Session { |
|
|
|
func Issues(opts *IssuesOptions) ([]*Issue, error) { |
|
|
|
sess := x.NewSession() |
|
|
|
|
|
|
|
|
|
|
|
if opts.Page <= 0 { |
|
|
|
if opts.Page <= 0 { |
|
|
|
opts.Page = 1 |
|
|
|
opts.Page = 1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sess := x.Limit(setting.UI.IssuePagingNum, (opts.Page-1)*setting.UI.IssuePagingNum) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if opts.RepoID > 0 { |
|
|
|
if opts.RepoID > 0 { |
|
|
|
sess.Where("issue.repo_id=?", opts.RepoID).And("issue.is_closed=?", opts.IsClosed) |
|
|
|
sess.Where("issue.repo_id=?", opts.RepoID).And("issue.is_closed=?", opts.IsClosed) |
|
|
|
} else if opts.RepoIDs != nil { |
|
|
|
} else if opts.RepoIDs != nil { |
|
|
|
// In case repository IDs are provided but actually no repository has issue.
|
|
|
|
// In case repository IDs are provided but actually no repository has issue.
|
|
|
|
if len(opts.RepoIDs) == 0 { |
|
|
|
if len(opts.RepoIDs) == 0 { |
|
|
|
return make([]*Issue, 0), nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
sess.In("issue.repo_id", base.Int64sToStrings(opts.RepoIDs)).And("issue.is_closed=?", opts.IsClosed) |
|
|
|
sess.In("issue.repo_id", base.Int64sToStrings(opts.RepoIDs)).And("issue.is_closed=?", opts.IsClosed) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -877,6 +876,28 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return sess |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// IssuesCount returns the number of issues by given conditions.
|
|
|
|
|
|
|
|
func IssuesCount(opts *IssuesOptions) (int64, error) { |
|
|
|
|
|
|
|
sess := buildIssuesQuery(opts) |
|
|
|
|
|
|
|
if sess == nil { |
|
|
|
|
|
|
|
return 0, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return sess.Count(&Issue{}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Issues returns a list of issues by given conditions.
|
|
|
|
|
|
|
|
func Issues(opts *IssuesOptions) ([]*Issue, error) { |
|
|
|
|
|
|
|
sess := buildIssuesQuery(opts) |
|
|
|
|
|
|
|
if sess == nil { |
|
|
|
|
|
|
|
return make([]*Issue, 0), nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sess.Limit(setting.UI.IssuePagingNum, (opts.Page-1)*setting.UI.IssuePagingNum) |
|
|
|
|
|
|
|
|
|
|
|
issues := make([]*Issue, 0, setting.UI.IssuePagingNum) |
|
|
|
issues := make([]*Issue, 0, setting.UI.IssuePagingNum) |
|
|
|
if err := sess.Find(&issues); err != nil { |
|
|
|
if err := sess.Find(&issues); err != nil { |
|
|
|
return nil, fmt.Errorf("Find: %v", err) |
|
|
|
return nil, fmt.Errorf("Find: %v", err) |
|
|
|