Backport #28552 by @6543
can we please PLEAS PLEASE only use raw SQL statements if it is relay
needed!!!
source is https://github.com/go-gitea/gitea/pull/28544 (before
refactoring)
Co-authored-by: 6543 <m.huber@kithara.com>
(cherry picked from commit 16263af971
)
This commit is contained in:
parent
40fa6a526a
commit
d350add668
1 changed files with 10 additions and 8 deletions
|
@ -461,8 +461,10 @@ func SubmitReview(ctx context.Context, doer *user_model.User, issue *Issue, revi
|
||||||
func GetReviewByIssueIDAndUserID(ctx context.Context, issueID, userID int64) (*Review, error) {
|
func GetReviewByIssueIDAndUserID(ctx context.Context, issueID, userID int64) (*Review, error) {
|
||||||
review := new(Review)
|
review := new(Review)
|
||||||
|
|
||||||
has, err := db.GetEngine(ctx).SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND reviewer_id = ? AND original_author_id = 0 AND type in (?, ?, ?))",
|
has, err := db.GetEngine(ctx).Where(
|
||||||
issueID, userID, ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest).
|
builder.In("type", ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest).
|
||||||
|
And(builder.Eq{"issue_id": issueID, "reviewer_id": userID, "original_author_id": 0})).
|
||||||
|
Desc("id").
|
||||||
Get(review)
|
Get(review)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -476,13 +478,13 @@ func GetReviewByIssueIDAndUserID(ctx context.Context, issueID, userID int64) (*R
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTeamReviewerByIssueIDAndTeamID get the latest review request of reviewer team for a pull request
|
// GetTeamReviewerByIssueIDAndTeamID get the latest review request of reviewer team for a pull request
|
||||||
func GetTeamReviewerByIssueIDAndTeamID(ctx context.Context, issueID, teamID int64) (review *Review, err error) {
|
func GetTeamReviewerByIssueIDAndTeamID(ctx context.Context, issueID, teamID int64) (*Review, error) {
|
||||||
review = new(Review)
|
review := new(Review)
|
||||||
|
|
||||||
var has bool
|
has, err := db.GetEngine(ctx).Where(builder.Eq{"issue_id": issueID, "reviewer_team_id": teamID}).
|
||||||
if has, err = db.GetEngine(ctx).SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND reviewer_team_id = ?)",
|
Desc("id").
|
||||||
issueID, teamID).
|
Get(review)
|
||||||
Get(review); err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue