Commit f4d762d7 authored by James Lopez's avatar James Lopez

addressing MR feedback, few changes to members mapper

parent e5cf4cd7
......@@ -10,29 +10,18 @@ module Gitlab
@project = project
@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.
ensure_default_member!
end
def map
@map ||= generate_map
end
def default_user_id
@user.id
end
private
def generate_map
@map ||=
begin
@exported_members.inject(missing_keys_tracking_hash) do |hash, member|
existing_user = User.where(find_project_user_query(member)).first
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
end
hash
......@@ -40,10 +29,16 @@ module Gitlab
end
end
def default_user_id
@user.id
end
private
def missing_keys_tracking_hash
Hash.new do |_, key|
@note_member_list << key
@user.id
default_user_id
end
end
......@@ -54,7 +49,7 @@ module Gitlab
def add_user_as_team_member(existing_user, member)
member['user'] = existing_user
ProjectMember.create(member_hash(member))
ProjectMember.create(member_hash(member)).persisted?
end
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