# - any other project member with developer access or higher (if there are no approvers
# left)
#
# It cannot be approved by:
# - a user who has already approved the MR
# - the MR author
#
defnumber_of_potential_approvers
has_access=['access_level > ?',Member::REPORTER]
wheres=[
"id IN (#{overall_approvers.select(:user_id).to_sql})",
...
...
@@ -575,21 +600,18 @@ class MergeRequest < ActiveRecord::Base
wheres<<"id IN (#{project.group.members.where(has_access).select(:user_id).to_sql})"
end
User.count_by_sql("SELECT COUNT(*) FROM users WHERE (#{wheres.join(' OR ')}) AND id NOT IN (#{approvals.select(:user_id).to_sql}) AND id != #{author.id}")
User.where("(#{wheres.join(' OR ')}) AND id NOT IN (#{approvals.select(:user_id).to_sql}) AND id != #{author.id}").count
end
# Users in the list of approvers who have not already approved this MR.