Skip to content

fix some bug about Request review #11040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions models/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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,
Expand Down
18 changes: 11 additions & 7 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,17 +661,21 @@ function initInstall() {
}

function initIssueComments() {
if ($('.repository.view.issue .comments').length === 0) return;
if ($('.repository.view.issue .timeline').length === 0) return;

$('.re-request-review').on('click', function (event) {
const url = $(this).data('update-url');
const issueId = $(this).data('issue-id');
const id = $(this).data('id');
const isChecked = $(this).data('is-checked');

$('.re-request-review').click((event) => {
const $this = $('.re-request-review');
event.preventDefault();
updateIssuesMeta(
$this.data('update-url'),
url,
'',
$this.data('issue-id'),
$this.data('id'),
$this.data('is-checked')
issueId,
id,
isChecked
).then(reload);
});

Expand Down