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
4a9dcfdc
Commit
4a9dcfdc
authored
Sep 03, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable AR caching, refactor tree hash loop
parent
a54c50d1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
12 deletions
+27
-12
lib/gitlab/import_export/project_tree_restorer.rb
lib/gitlab/import_export/project_tree_restorer.rb
+27
-12
No files found.
lib/gitlab/import_export/project_tree_restorer.rb
View file @
4a9dcfdc
...
@@ -23,9 +23,11 @@ module Gitlab
...
@@ -23,9 +23,11 @@ module Gitlab
@project_members
=
@tree_hash
.
delete
(
'project_members'
)
@project_members
=
@tree_hash
.
delete
(
'project_members'
)
ActiveRecord
::
Base
.
uncached
do
ActiveRecord
::
Base
.
no_touching
do
ActiveRecord
::
Base
.
no_touching
do
create_relations
create_relations
end
end
end
rescue
=>
e
rescue
=>
e
@shared
.
error
(
e
)
@shared
.
error
(
e
)
false
false
...
@@ -52,6 +54,7 @@ module Gitlab
...
@@ -52,6 +54,7 @@ module Gitlab
@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
)
if
relation
.
is_a?
(
Hash
)
create_sub_relations
(
relation
,
@tree_hash
)
create_sub_relations
(
relation
,
@tree_hash
)
else
else
...
@@ -82,6 +85,10 @@ module Gitlab
...
@@ -82,6 +85,10 @@ 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
...
@@ -117,7 +124,9 @@ module Gitlab
...
@@ -117,7 +124,9 @@ module Gitlab
relation_key
=
relation
.
keys
.
first
.
to_s
relation_key
=
relation
.
keys
.
first
.
to_s
return
if
tree_hash
[
relation_key
].
blank?
return
if
tree_hash
[
relation_key
].
blank?
[
tree_hash
[
relation_key
]].
flatten
.
each
do
|
relation_item
|
tree_array
=
[
tree_hash
[
relation_key
]].
flatten
while
relation_item
=
tree_array
.
shift
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
...
@@ -128,9 +137,15 @@ module Gitlab
...
@@ -128,9 +137,15 @@ module Gitlab
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
)
if
save
if
save
tree_hash
.
delete
(
relation_key
)
if
save
save_relation_hash
([
relation_item
],
relation_key
)
end
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
)
...
...
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