summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
author赵智超 <1012112796@qq.com>2020-04-11 12:44:50 +0800
committerGitHub <noreply@github.com>2020-04-11 01:44:50 -0300
commitcc07b9ca3773573144263e4293f7a2ca7e3b9e5e (patch)
treed1030819346fe245b87e119671a1243f8cb01dd5 /models
parent8592fb7121874f7998e0df10c3c7e6777eb78033 (diff)
downloadgitea-cc07b9ca3773573144263e4293f7a2ca7e3b9e5e.tar.gz
gitea-cc07b9ca3773573144263e4293f7a2ca7e3b9e5e.zip
Fix CreateComment for SQLite and JS click event on Request Review (#11040)
* fix some bug about Request review * fix ``CreateComment`` wrong using ,it will not work when use Sqlite * fix wrong js click event code , it will send wrong data when it has many choices Signed-off-by: a1012112796 <1012112796@qq.com> * Apply suggestions from code review Co-Authored-By: Lauris BH <lauris@nix.lv> * add getReviewerByIssueIDAndUserID fix wrong conditions check in initIssueComments after #10972 * call CI again Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Diffstat (limited to 'models')
-rw-r--r--models/review.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/models/review.go b/models/review.go
index 3f7223154e..d6bb77925e 100644
--- a/models/review.go
+++ b/models/review.go
@@ -395,9 +395,13 @@ func GetReviewersByIssueID(issueID int64) (reviews []*Review, err error) {
// GetReviewerByIssueIDAndUserID get the latest review of reviewer for a pull request
func GetReviewerByIssueIDAndUserID(issueID, userID int64) (review *Review, err error) {
+ return getReviewerByIssueIDAndUserID(x, issueID, userID)
+}
+
+func getReviewerByIssueIDAndUserID(e Engine, issueID, userID int64) (review *Review, err error) {
review = new(Review)
- if _, err := x.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND reviewer_id = ? AND type in (?, ?, ?))",
+ if _, err := e.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND reviewer_id = ? AND type in (?, ?, ?))",
issueID, userID, ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest).
Get(review); err != nil {
return nil, err
@@ -559,7 +563,7 @@ func RemoveRewiewRequest(issue *Issue, reviewer *User, doer *User) (comment *Com
// recalculate which is the latest official review from that user
var review *Review
- review, err = GetReviewerByIssueIDAndUserID(issue.ID, reviewer.ID)
+ review, err = getReviewerByIssueIDAndUserID(sess, issue.ID, reviewer.ID)
if err != nil {
return nil, err
}
@@ -575,7 +579,7 @@ func RemoveRewiewRequest(issue *Issue, reviewer *User, doer *User) (comment *Com
return nil, err
}
- comment, err = CreateComment(&CreateCommentOptions{
+ comment, err = createComment(sess, &CreateCommentOptions{
Type: CommentTypeReviewRequest,
Doer: doer,
Repo: issue.Repo,