summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorNanguan Lin <70063547+lng2020@users.noreply.github.com>2023-09-03 10:12:38 +0800
committerGitHub <noreply@github.com>2023-09-03 02:12:38 +0000
commitf1fe102c8c9146f8cb997779a4e802691cd1d366 (patch)
tree57f3895d1647fe7600e96962d1bd6afd6b9620e8 /models
parentc802c46a9beeaed44d41f50de31a4db146cdd8f7 (diff)
downloadgitea-f1fe102c8c9146f8cb997779a4e802691cd1d366.tar.gz
gitea-f1fe102c8c9146f8cb997779a4e802691cd1d366.zip
Fix wrong review requested number (#26784)
Fix the wrong review requested number mentioned by #18808 . Fix #18808 Before: ![ksnip_20230829-140750](https://github.com/go-gitea/gitea/assets/70063547/0af2055b-6f16-4699-a944-c7186831d7f9) After: ![ksnip_20230829-141817](https://github.com/go-gitea/gitea/assets/70063547/16633264-20ba-45e3-bfbb-a495ed76a45b)
Diffstat (limited to 'models')
-rw-r--r--models/issues/issue_search.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/models/issues/issue_search.go b/models/issues/issue_search.go
index 3640351a4d..5d40b44704 100644
--- a/models/issues/issue_search.go
+++ b/models/issues/issue_search.go
@@ -358,12 +358,21 @@ func applyMentionedCondition(sess *xorm.Session, mentionedID int64) *xorm.Sessio
}
func applyReviewRequestedCondition(sess *xorm.Session, reviewRequestedID int64) *xorm.Session {
- return sess.Join("INNER", []string{"review", "r"}, "issue.id = r.issue_id").
- And("issue.poster_id <> ?", reviewRequestedID).
- And("r.type = ?", ReviewTypeRequest).
- And("r.reviewer_id = ? and r.id in (select max(id) from review where issue_id = r.issue_id and reviewer_id = r.reviewer_id and type in (?, ?, ?))"+
- " or r.reviewer_team_id in (select team_id from team_user where uid = ?)",
- reviewRequestedID, ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest, reviewRequestedID)
+ existInTeamQuery := builder.Select("team_user.team_id").
+ From("team_user").
+ Where(builder.Eq{"team_user.uid": reviewRequestedID})
+
+ subQuery := builder.Select("review.issue_id").
+ From("review").
+ Where(builder.And(
+ builder.In("review.type", []ReviewType{ReviewTypeRequest, ReviewTypeReject, ReviewTypeApprove}),
+ builder.Or(
+ builder.Eq{"review.reviewer_id": reviewRequestedID},
+ builder.In("review.reviewer_team_id", existInTeamQuery),
+ ),
+ ))
+ return sess.Where("issue.poster_id <> ?", reviewRequestedID).
+ And(builder.In("issue.id", subQuery))
}
func applyReviewedCondition(sess *xorm.Session, reviewedID int64) *xorm.Session {