BigW Consortium Gitlab

Commit f4d762d7 by James Lopez

addressing MR feedback, few changes to members mapper

parent e5cf4cd7
...@@ -10,29 +10,18 @@ module Gitlab ...@@ -10,29 +10,18 @@ module Gitlab
@project = project @project = project
@note_member_list = [] @note_member_list = []
# This needs to run first, as second call would be from generate_map # This needs to run first, as second call would be from #map
# which means project members already exist. # which means project members already exist.
ensure_default_member! ensure_default_member!
end end
def map def map
@map ||= generate_map
end
def default_user_id
@user.id
end
private
def generate_map
@map ||= @map ||=
begin begin
@exported_members.inject(missing_keys_tracking_hash) do |hash, member| @exported_members.inject(missing_keys_tracking_hash) do |hash, member|
existing_user = User.where(find_project_user_query(member)).first existing_user = User.where(find_project_user_query(member)).first
old_user_id = member['user']['id'] old_user_id = member['user']['id']
if existing_user && add_user_as_team_member(existing_user, member).persisted? if existing_user && add_user_as_team_member(existing_user, member)
hash[old_user_id] = existing_user.id hash[old_user_id] = existing_user.id
end end
hash hash
...@@ -40,10 +29,16 @@ module Gitlab ...@@ -40,10 +29,16 @@ module Gitlab
end end
end end
def default_user_id
@user.id
end
private
def missing_keys_tracking_hash def missing_keys_tracking_hash
Hash.new do |_, key| Hash.new do |_, key|
@note_member_list << key @note_member_list << key
@user.id default_user_id
end end
end end
...@@ -54,7 +49,7 @@ module Gitlab ...@@ -54,7 +49,7 @@ module Gitlab
def add_user_as_team_member(existing_user, member) def add_user_as_team_member(existing_user, member)
member['user'] = existing_user member['user'] = existing_user
ProjectMember.create(member_hash(member)) ProjectMember.create(member_hash(member)).persisted?
end end
def member_hash(member) def member_hash(member)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment