mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-28 03:00:03 +02:00
This reverts commit 78438d310b
.
This commit is contained in:
parent
78438d310b
commit
170743c8a0
5 changed files with 177 additions and 109 deletions
|
@ -1306,19 +1306,18 @@ func GetIssuesByIDs(issueIDs []int64) ([]*Issue, error) {
|
|||
|
||||
// IssuesOptions represents options of an issue.
|
||||
type IssuesOptions struct {
|
||||
RepoIDs []int64 // include all repos if empty
|
||||
RepoSubQuery *builder.Builder
|
||||
AssigneeID int64
|
||||
PosterID int64
|
||||
MentionedID int64
|
||||
MilestoneID int64
|
||||
Page int
|
||||
PageSize int
|
||||
IsClosed util.OptionalBool
|
||||
IsPull util.OptionalBool
|
||||
LabelIDs []int64
|
||||
SortType string
|
||||
IssueIDs []int64
|
||||
RepoIDs []int64 // include all repos if empty
|
||||
AssigneeID int64
|
||||
PosterID int64
|
||||
MentionedID int64
|
||||
MilestoneID int64
|
||||
Page int
|
||||
PageSize int
|
||||
IsClosed util.OptionalBool
|
||||
IsPull util.OptionalBool
|
||||
LabelIDs []int64
|
||||
SortType string
|
||||
IssueIDs []int64
|
||||
}
|
||||
|
||||
// sortIssuesSession sort an issues-related session based on the provided
|
||||
|
@ -1361,9 +1360,7 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) {
|
|||
sess.In("issue.id", opts.IssueIDs)
|
||||
}
|
||||
|
||||
if opts.RepoSubQuery != nil {
|
||||
sess.In("issue.repo_id", opts.RepoSubQuery)
|
||||
} else if len(opts.RepoIDs) > 0 {
|
||||
if len(opts.RepoIDs) > 0 {
|
||||
// In case repository IDs are provided but actually no repository has issue.
|
||||
sess.In("issue.repo_id", opts.RepoIDs)
|
||||
}
|
||||
|
@ -1630,12 +1627,12 @@ func GetIssueStats(opts *IssueStatsOptions) (*IssueStats, error) {
|
|||
|
||||
// UserIssueStatsOptions contains parameters accepted by GetUserIssueStats.
|
||||
type UserIssueStatsOptions struct {
|
||||
UserID int64
|
||||
RepoID int64
|
||||
RepoSubQuery *builder.Builder
|
||||
FilterMode int
|
||||
IsPull bool
|
||||
IsClosed bool
|
||||
UserID int64
|
||||
RepoID int64
|
||||
UserRepoIDs []int64
|
||||
FilterMode int
|
||||
IsPull bool
|
||||
IsClosed bool
|
||||
}
|
||||
|
||||
// GetUserIssueStats returns issue statistic information for dashboard by given conditions.
|
||||
|
@ -1649,23 +1646,16 @@ func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error) {
|
|||
cond = cond.And(builder.Eq{"issue.repo_id": opts.RepoID})
|
||||
}
|
||||
|
||||
var repoCond = builder.NewCond()
|
||||
if opts.RepoSubQuery != nil {
|
||||
repoCond = builder.In("issue.repo_id", opts.RepoSubQuery)
|
||||
} else {
|
||||
repoCond = builder.Expr("0=1")
|
||||
}
|
||||
|
||||
switch opts.FilterMode {
|
||||
case FilterModeAll:
|
||||
stats.OpenCount, err = x.Where(cond).And("is_closed = ?", false).
|
||||
And(repoCond).
|
||||
And(builder.In("issue.repo_id", opts.UserRepoIDs)).
|
||||
Count(new(Issue))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stats.ClosedCount, err = x.Where(cond).And("is_closed = ?", true).
|
||||
And(repoCond).
|
||||
And(builder.In("issue.repo_id", opts.UserRepoIDs)).
|
||||
Count(new(Issue))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1740,7 +1730,7 @@ func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error) {
|
|||
}
|
||||
|
||||
stats.YourRepositoriesCount, err = x.Where(cond).
|
||||
And(repoCond).
|
||||
And(builder.In("issue.repo_id", opts.UserRepoIDs)).
|
||||
Count(new(Issue))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue