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
8645c763
Commit
8645c763
authored
Dec 17, 2019
by
nmilojevic1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preload project, user and group to reuse objects
parent
2be380d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+22
-1
No files found.
lib/gitlab/import_export/relation_factory.rb
View file @
8645c763
...
...
@@ -34,6 +34,8 @@ module Gitlab
PROJECT_REFERENCES
=
%w[project_id source_project_id target_project_id]
.
freeze
GROUP_REFERENCES
=
%w[group_id]
.
freeze
BUILD_MODELS
=
%i[Ci::Build commit_status]
.
freeze
IMPORTED_OBJECT_MAX_RETRIES
=
5
.
freeze
...
...
@@ -89,7 +91,13 @@ module Gitlab
setup_models
generate_imported_object
object
=
generate_imported_object
# We preload the project, user, and group to re-use objects
object
=
preload_keys
(
object
,
PROJECT_REFERENCES
,
@project
)
object
=
preload_keys
(
object
,
GROUP_REFERENCES
,
@project
.
group
)
object
=
preload_keys
(
object
,
USER_REFERENCES
,
@user
)
object
end
def
self
.
overrides
...
...
@@ -122,6 +130,19 @@ module Gitlab
remove_encrypted_attributes!
end
def
preload_keys
(
object
,
references
,
value
)
references
.
each
do
|
key
|
setter
=
"
#{
key
.
delete_suffix
(
'_id'
)
}
="
.
to_sym
next
unless
object
.
respond_to?
(
key
)
&&
object
.
respond_to?
(
setter
)
if
object
.
public_send
(
key
)
==
value
&
.
id
object
.
public_send
(
setter
,
value
)
end
end
object
end
def
update_user_references
USER_REFERENCES
.
each
do
|
reference
|
if
@relation_hash
[
reference
]
...
...
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