Skip to content

Commit

Permalink
[frontend] Move existing private methods together
Browse files Browse the repository at this point in the history
We already had some private methods that were marked as private
individually. This will group them together to have a better overview
of them.
  • Loading branch information
bgeuken committed Oct 11, 2017
1 parent 9812972 commit ae97338
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions src/api/app/models/bs_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -572,38 +572,6 @@ def change_state(opts)
end
end

def _assignreview_update_reviews(reviewer, opts, new_review = nil)
review_comment = nil
reviews.reverse_each do |review|
next if review.by_user
next if review.by_group && review.by_group != opts[:by_group]
next if review.by_project && review.by_project != opts[:by_project]
next if review.by_package && review.by_package != opts[:by_package]

# approve for this review
if opts[:revert]
review.state = :new
review_comment = "revert the "
history_class = HistoryElement::ReviewReopened
else
review.state = :accepted
review.review_assigned_to = new_review if new_review
review_comment = ""
history_class = HistoryElement::ReviewAccepted
end
review.reviewer = User.current.try(:login)
review.save!

review_comment += "review for group #{opts[:by_group]}" if opts[:by_group]
review_comment += "review for project #{opts[:by_project]}" if opts[:by_project]
review_comment += "review for package #{opts[:by_project]} / #{opts[:by_package]}" if opts[:by_package]
history_class.create(review: review, comment: "review assigend to user #{reviewer.login}", user_id: User.current.id)
end
raise Review::NotFoundError unless review_comment
review_comment
end
private :_assignreview_update_reviews

def assignreview(opts = {})
unless state == :review || (state == :new && state == :new)
raise InvalidStateError, 'request is not in review state'
Expand Down Expand Up @@ -1215,6 +1183,36 @@ def check_bs_request_actions!(opts = {})
end
end

def _assignreview_update_reviews(reviewer, opts, new_review = nil)
review_comment = nil
reviews.reverse_each do |review|
next if review.by_user
next if review.by_group && review.by_group != opts[:by_group]
next if review.by_project && review.by_project != opts[:by_project]
next if review.by_package && review.by_package != opts[:by_package]

# approve for this review
if opts[:revert]
review.state = :new
review_comment = "revert the "
history_class = HistoryElement::ReviewReopened
else
review.state = :accepted
review.review_assigned_to = new_review if new_review
review_comment = ""
history_class = HistoryElement::ReviewAccepted
end
review.reviewer = User.current.try(:login)
review.save!

review_comment += "review for group #{opts[:by_group]}" if opts[:by_group]
review_comment += "review for project #{opts[:by_project]}" if opts[:by_project]
review_comment += "review for package #{opts[:by_project]} / #{opts[:by_package]}" if opts[:by_package]
history_class.create(review: review, comment: "review assigend to user #{reviewer.login}", user_id: User.current.id)
end
raise Review::NotFoundError unless review_comment
review_comment
end
end

# == Schema Information
Expand Down

0 comments on commit ae97338

Please sign in to comment.