Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
12 deletions
+33
-12
lib/gitlab/import_export/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
...
@@ -9,6 +9,7 @@ module Gitlab
@user
=
user
@user
=
user
@shared
=
shared
@shared
=
shared
@project
=
project
@project
=
project
@project_id
=
project
.
id
end
end
def
restore
def
restore
...
@@ -48,24 +49,42 @@ module Gitlab
...
@@ -48,24 +49,42 @@ module Gitlab
# the configuration yaml file too.
# the configuration yaml file too.
# Finally, it updates each attribute in the newly imported project.
# Finally, it updates each attribute in the newly imported project.
def
create_relations
def
create_relations
saved
=
[]
@
saved
=
[]
default_relation_list
.
each
do
|
relation
|
default_relation_list
.
each
do
|
relation
|
next
unless
relation
.
is_a?
(
Hash
)
||
@tree_hash
[
relation
.
to_s
].
present?
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_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]
#
# 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
)
@project
=
Project
.
find_by_id
(
@project_id
)
saved
<<
restored_project
.
append_or_update_attribute
(
relation_key
,
relation_hash
)
end
end
saved
.
all?
end
end
def
default_relation_list
def
default_relation_list
...
@@ -80,7 +99,7 @@ module Gitlab
...
@@ -80,7 +99,7 @@ module Gitlab
@project
.
update_columns
(
project_params
)
@project
.
update_columns
(
project_params
)
@project
@project
end
end
git
che
def
project_params
def
project_params
@tree_hash
.
reject
do
|
key
,
value
|
@tree_hash
.
reject
do
|
key
,
value
|
# return params that are not 1 to many or 1 to 1 relations
# return params that are not 1 to many or 1 to 1 relations
...
@@ -110,6 +129,8 @@ git che
...
@@ -110,6 +129,8 @@ git che
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
save_relation_hash
(
relation_item
,
relation_key
)
end
end
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