class.self methods moved to scopes

This commit is contained in:
Andrew8xx8 2013-02-20 17:37:20 +04:00
parent e2d94e0719
commit 52e0df5c23
2 changed files with 4 additions and 19 deletions

View file

@ -81,24 +81,9 @@ class MergeRequest < ActiveRecord::Base
validate :validate_branches validate :validate_branches
scope :merged, -> { with_state(:merged) } scope :merged, -> { with_state(:merged) }
scope :by_branch, ->(branch_name) { where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name) }
class << self scope :cared, ->(user) { where('assignee_id = :user OR author_id = :user', user: user.id) }
def find_all_by_branch(branch_name) scope :by_milestone, ->(milestone) { where("milestone_id = :milestone_id", milestone_id: milestone) }
where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name)
end
def cared(user)
where('assignee_id = :user OR author_id = :user', user: user.id)
end
def find_all_by_branch(branch_name)
where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name)
end
def find_all_by_milestone(milestone)
where("milestone_id = :milestone_id", milestone_id: milestone)
end
end
# DEPRECATED: Please use human_merge_status_name instead # DEPRECATED: Please use human_merge_status_name instead
def human_merge_status def human_merge_status

View file

@ -424,7 +424,7 @@ class Project < ActiveRecord::Base
c_ids = self.repository.commits_between(oldrev, newrev).map(&:id) c_ids = self.repository.commits_between(oldrev, newrev).map(&:id)
# Update code for merge requests # Update code for merge requests
mrs = self.merge_requests.opened.find_all_by_branch(branch_name).all mrs = self.merge_requests.opened.by_branch(branch_name).all
mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked } mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked }
# Close merge requests # Close merge requests