BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
690b9865
Commit
690b9865
authored
Sep 01, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some more performance refactoring
parent
0085f5e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
12 deletions
+33
-12
project_tree_restorer.rb
lib/gitlab/import_export/project_tree_restorer.rb
+33
-12
No files found.
lib/gitlab/import_export/project_tree_restorer.rb
View file @
690b9865
...
...
@@ -9,6 +9,7 @@ module Gitlab
@user
=
user
@shared
=
shared
@project
=
project
@project_id
=
project
.
id
end
def
restore
...
...
@@ -48,24 +49,42 @@ module Gitlab
# the configuration yaml file too.
# Finally, it updates each attribute in the newly imported project.
def
create_relations
saved
=
[]
@
saved
=
[]
default_relation_list
.
each
do
|
relation
|
next
unless
relation
.
is_a?
(
Hash
)
||
@tree_hash
[
relation
.
to_s
].
present?
if
relation
.
is_a?
(
Hash
)
create_sub_relations
(
relation
,
@tree_hash
)
else
relation_key
=
relation
.
is_a?
(
Hash
)
?
relation
.
keys
.
first
:
relation
relation_hash_list
=
@tree_hash
[
relation_key
.
to_s
]
save_relation_hash
(
relation_hash_list
,
relation_key
,
saved
)
end
create_sub_relations
(
relation
,
@tree_hash
)
if
relation
.
is_a?
(
Hash
)
relation_key
=
relation
.
is_a?
(
Hash
)
?
relation
.
keys
.
first
:
relation
relation_hash_list
=
@tree_hash
[
relation_key
.
to_s
]
# relation_key = relation.is_a?(Hash) ? relation.keys.first : relation
# relation_hash_list = @tree_hash[relation_key.to_s]
#
# next unless relation_hash_list
#
# if relation_hash_list.is_a?(Array)
# [relation_hash_list].flatten.each_slice(15) do |relation_hash_batch|
# save_relation_hash(relation_hash_batch, relation_key, saved)
# end
# else
# save_relation_hash(relation_hash_list, relation_key, saved)
# end
next
unless
relation_hash_list
end
@saved
.
all?
end
[
relation_hash_list
].
flatten
.
each_slice
(
10
)
do
|
relation_hash_batch
|
def
save_relation_hash
(
relation_hash_batch
,
relation_key
)
relation_hash
=
create_relation
(
relation_key
,
relation_hash_batch
)
@saved
<<
restored_project
.
append_or_update_attribute
(
relation_key
,
relation_hash
)
@restored_project
=
nil
@project
=
nil
relation_hash
=
create_relation
(
relation_key
,
relation_hash_batch
)
saved
<<
restored_project
.
append_or_update_attribute
(
relation_key
,
relation_hash
)
end
end
saved
.
all?
@project
=
Project
.
find_by_id
(
@project_id
)
end
def
default_relation_list
...
...
@@ -80,7 +99,7 @@ module Gitlab
@project
.
update_columns
(
project_params
)
@project
end
git
che
def
project_params
@tree_hash
.
reject
do
|
key
,
value
|
# return params that are not 1 to many or 1 to 1 relations
...
...
@@ -110,6 +129,8 @@ git che
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?
end
save_relation_hash
(
relation_item
,
relation_key
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment