@@ -10,6 +10,7 @@ import (
10
10
repo_model "code.gitea.io/gitea/models/repo"
11
11
user_model "code.gitea.io/gitea/models/user"
12
12
"code.gitea.io/gitea/modules/container"
13
+ "code.gitea.io/gitea/modules/log"
13
14
)
14
15
15
16
// CommentList defines a list of comments
@@ -422,37 +423,18 @@ func (comments CommentList) loadReviews(ctx context.Context) error {
422
423
423
424
reviewIDs := comments .getReviewIDs ()
424
425
reviews := make (map [int64 ]* Review , len (reviewIDs ))
425
- left := len (reviewIDs )
426
- for left > 0 {
427
- limit := db .DefaultMaxInSize
428
- if left < limit {
429
- limit = left
430
- }
431
- rows , err := db .GetEngine (ctx ).
432
- In ("id" , reviewIDs [:limit ]).
433
- Rows (new (Review ))
434
- if err != nil {
435
- return err
436
- }
437
-
438
- for rows .Next () {
439
- var review Review
440
- err = rows .Scan (& review )
441
- if err != nil {
442
- _ = rows .Close ()
443
- return err
444
- }
445
-
446
- reviews [review .ID ] = & review
447
- }
448
- _ = rows .Close ()
449
-
450
- left -= limit
451
- reviewIDs = reviewIDs [limit :]
426
+ if err := db .GetEngine (ctx ).In ("id" , reviewIDs ).Find (& reviews ); err != nil {
427
+ return err
452
428
}
453
429
454
430
for _ , comment := range comments {
455
431
comment .Review = reviews [comment .ReviewID ]
432
+ if comment .Review == nil {
433
+ if comment .ReviewID > 0 {
434
+ log .Error ("comment with review id [%d] but has no review record" , comment .ReviewID )
435
+ }
436
+ continue
437
+ }
456
438
457
439
// If the comment dismisses a review, we need to load the reviewer to show whose review has been dismissed.
458
440
// Otherwise, the reviewer is the poster of the comment, so we don't need to load it.
0 commit comments