1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-22 16:44:26 +00:00

Use more IssueList instead of []*Issue (#26369)

This commit is contained in:
Lunny Xiao 2023-08-08 03:26:40 +08:00 committed by GitHub
parent ab0eb1c47b
commit f5dbac9d36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

View File

@ -854,8 +854,8 @@ func (issue *Issue) MovePin(ctx context.Context, newPosition int) error {
} }
// GetPinnedIssues returns the pinned Issues for the given Repo and type // GetPinnedIssues returns the pinned Issues for the given Repo and type
func GetPinnedIssues(ctx context.Context, repoID int64, isPull bool) ([]*Issue, error) { func GetPinnedIssues(ctx context.Context, repoID int64, isPull bool) (IssueList, error) {
issues := make([]*Issue, 0) issues := make(IssueList, 0)
err := db.GetEngine(ctx). err := db.GetEngine(ctx).
Table("issue"). Table("issue").
@ -868,7 +868,7 @@ func GetPinnedIssues(ctx context.Context, repoID int64, isPull bool) ([]*Issue,
return nil, err return nil, err
} }
err = IssueList(issues).LoadAttributes(ctx) err = issues.LoadAttributes(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -53,7 +53,7 @@ func (issue *Issue) projectBoardID(ctx context.Context) int64 {
// LoadIssuesFromBoard load issues assigned to this board // LoadIssuesFromBoard load issues assigned to this board
func LoadIssuesFromBoard(ctx context.Context, b *project_model.Board) (IssueList, error) { func LoadIssuesFromBoard(ctx context.Context, b *project_model.Board) (IssueList, error) {
issueList := make([]*Issue, 0, 10) issueList := make(IssueList, 0, 10)
if b.ID != 0 { if b.ID != 0 {
issues, err := Issues(ctx, &IssuesOptions{ issues, err := Issues(ctx, &IssuesOptions{
@ -79,7 +79,7 @@ func LoadIssuesFromBoard(ctx context.Context, b *project_model.Board) (IssueList
issueList = append(issueList, issues...) issueList = append(issueList, issues...)
} }
if err := IssueList(issueList).LoadComments(ctx); err != nil { if err := issueList.LoadComments(ctx); err != nil {
return nil, err return nil, err
} }

View File

@ -441,7 +441,7 @@ func GetRepoIDsForIssuesOptions(opts *IssuesOptions, user *user_model.User) ([]i
} }
// Issues returns a list of issues by given conditions. // Issues returns a list of issues by given conditions.
func Issues(ctx context.Context, opts *IssuesOptions) ([]*Issue, error) { func Issues(ctx context.Context, opts *IssuesOptions) (IssueList, error) {
sess := db.GetEngine(ctx). sess := db.GetEngine(ctx).
Join("INNER", "repository", "`issue`.repo_id = `repository`.id") Join("INNER", "repository", "`issue`.repo_id = `repository`.id")
applyLimit(sess, opts) applyLimit(sess, opts)

View File

@ -296,8 +296,7 @@ func NotificationSubscriptions(ctx *context.Context) {
} }
ctx.Data["CommitStatus"] = commitStatus ctx.Data["CommitStatus"] = commitStatus
issueList := issues_model.IssueList(issues) approvalCounts, err := issues.GetApprovalCounts(ctx)
approvalCounts, err := issueList.GetApprovalCounts(ctx)
if err != nil { if err != nil {
ctx.ServerError("ApprovalCounts", err) ctx.ServerError("ApprovalCounts", err)
return return