loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use `CommentList` instead of `[]*Comment` (#24828)

As title.

authored by

Lunny Xiao and committed by
GitHub
64f6a5d1 edd8ea0b

+13 -13
+1 -1
models/issues/comment.go
··· 1048 1048 } 1049 1049 1050 1050 // FindComments returns all comments according options 1051 - func FindComments(ctx context.Context, opts *FindCommentsOptions) ([]*Comment, error) { 1051 + func FindComments(ctx context.Context, opts *FindCommentsOptions) (CommentList, error) { 1052 1052 comments := make([]*Comment, 0, 10) 1053 1053 sess := db.GetEngine(ctx).Where(opts.ToConds()) 1054 1054 if opts.RepoID > 0 {
+2 -2
models/issues/comment_code.go
··· 48 48 } 49 49 50 50 func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issue, currentUser *user_model.User, review *Review) ([]*Comment, error) { 51 - var comments []*Comment 51 + var comments CommentList 52 52 if review == nil { 53 53 review = &Review{ID: 0} 54 54 } ··· 68 68 return nil, err 69 69 } 70 70 71 - if err := CommentList(comments).LoadPosters(ctx); err != nil { 71 + if err := comments.LoadPosters(ctx); err != nil { 72 72 return nil, err 73 73 } 74 74
+2 -2
models/issues/issue.go
··· 124 124 ClosedUnix timeutil.TimeStamp `xorm:"INDEX"` 125 125 126 126 Attachments []*repo_model.Attachment `xorm:"-"` 127 - Comments []*Comment `xorm:"-"` 127 + Comments CommentList `xorm:"-"` 128 128 Reactions ReactionList `xorm:"-"` 129 129 TotalTrackedTime int64 `xorm:"-"` 130 130 Assignees []*user_model.User `xorm:"-"` ··· 353 353 return err 354 354 } 355 355 356 - if err = CommentList(issue.Comments).loadAttributes(ctx); err != nil { 356 + if err = issue.Comments.loadAttributes(ctx); err != nil { 357 357 return err 358 358 } 359 359 if issue.IsTimetrackerEnabled(ctx) {
+8 -8
routers/api/v1/repo/issue_comment.go
··· 90 90 return 91 91 } 92 92 93 - if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil { 93 + if err := comments.LoadPosters(ctx); err != nil { 94 94 ctx.Error(http.StatusInternalServerError, "LoadPosters", err) 95 95 return 96 96 } 97 97 98 - if err := issues_model.CommentList(comments).LoadAttachments(ctx); err != nil { 98 + if err := comments.LoadAttachments(ctx); err != nil { 99 99 ctx.Error(http.StatusInternalServerError, "LoadAttachments", err) 100 100 return 101 101 } ··· 182 182 return 183 183 } 184 184 185 - if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil { 185 + if err := comments.LoadPosters(ctx); err != nil { 186 186 ctx.Error(http.StatusInternalServerError, "LoadPosters", err) 187 187 return 188 188 } ··· 285 285 return 286 286 } 287 287 288 - if err = issues_model.CommentList(comments).LoadPosters(ctx); err != nil { 288 + if err = comments.LoadPosters(ctx); err != nil { 289 289 ctx.Error(http.StatusInternalServerError, "LoadPosters", err) 290 290 return 291 291 } 292 292 293 293 apiComments := make([]*api.Comment, len(comments)) 294 - if err := issues_model.CommentList(comments).LoadIssues(ctx); err != nil { 294 + if err := comments.LoadIssues(ctx); err != nil { 295 295 ctx.Error(http.StatusInternalServerError, "LoadIssues", err) 296 296 return 297 297 } 298 - if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil { 298 + if err := comments.LoadPosters(ctx); err != nil { 299 299 ctx.Error(http.StatusInternalServerError, "LoadPosters", err) 300 300 return 301 301 } 302 - if err := issues_model.CommentList(comments).LoadAttachments(ctx); err != nil { 302 + if err := comments.LoadAttachments(ctx); err != nil { 303 303 ctx.Error(http.StatusInternalServerError, "LoadAttachments", err) 304 304 return 305 305 } 306 - if _, err := issues_model.CommentList(comments).Issues().LoadRepositories(ctx); err != nil { 306 + if _, err := comments.Issues().LoadRepositories(ctx); err != nil { 307 307 ctx.Error(http.StatusInternalServerError, "LoadRepositories", err) 308 308 return 309 309 }