Commit d3348474 authored by James Lopez's avatar James Lopez

some more refactoring

parent 4a9dcfdc
...@@ -60,7 +60,7 @@ module Gitlab ...@@ -60,7 +60,7 @@ module Gitlab
else else
relation_key = relation.is_a?(Hash) ? relation.keys.first : relation relation_key = relation.is_a?(Hash) ? relation.keys.first : relation
relation_hash_list = @tree_hash[relation_key.to_s] relation_hash_list = @tree_hash[relation_key.to_s]
save_relation_hash(relation_hash_list, relation_key, @saved) save_relation_hash(relation_hash_list, relation_key)
end end
...@@ -85,10 +85,6 @@ module Gitlab ...@@ -85,10 +85,6 @@ module Gitlab
relation_hash = create_relation(relation_key, relation_hash_batch) relation_hash = create_relation(relation_key, relation_hash_batch)
@saved << restored_project.append_or_update_attribute(relation_key, relation_hash) @saved << restored_project.append_or_update_attribute(relation_key, relation_hash)
@restored_project = nil
@project = nil
relation_hash = nil
relation_hash_batch = nil
@restored_project = Project.find_by_id(@project_id) @restored_project = Project.find_by_id(@project_id)
end end
...@@ -127,6 +123,18 @@ module Gitlab ...@@ -127,6 +123,18 @@ module Gitlab
tree_array = [tree_hash[relation_key]].flatten tree_array = [tree_hash[relation_key]].flatten
while relation_item = tree_array.shift while relation_item = tree_array.shift
process_sub_relation(relation, relation_item)
if save
save_relation_hash([relation_item], relation_key)
tree_hash[relation_key].delete(relation_item)
end
end
tree_hash.delete(relation_key) if save
end
def process_sub_relation(relation, relation_item)
relation.values.flatten.each do |sub_relation| relation.values.flatten.each do |sub_relation|
# We just use author to get the user ID, do not attempt to create an instance. # We just use author to get the user ID, do not attempt to create an instance.
next if sub_relation == :author next if sub_relation == :author
...@@ -136,16 +144,6 @@ module Gitlab ...@@ -136,16 +144,6 @@ module Gitlab
relation_hash, sub_relation = assign_relation_hash(relation_item, sub_relation) relation_hash, sub_relation = assign_relation_hash(relation_item, sub_relation)
relation_item[sub_relation.to_s] = create_relation(sub_relation, relation_hash) unless relation_hash.blank? relation_item[sub_relation.to_s] = create_relation(sub_relation, relation_hash) unless relation_hash.blank?
end end
if save
save_relation_hash([relation_item], relation_key)
end
tree_hash[relation_key].delete(relation_item) if save
relation_item = nil
end
tree_hash.delete(relation_key) if save
end end
def assign_relation_hash(relation_item, sub_relation) def assign_relation_hash(relation_item, sub_relation)
......
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