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
2a7a1bcc
Commit
2a7a1bcc
authored
Mar 10, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored methods in project tree restorer
parent
e90b1e14
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
project_tree_restorer.rb
app/services/projects/import_export/project_tree_restorer.rb
+10
-6
No files found.
app/services/projects/import_export/project_tree_restorer.rb
View file @
2a7a1bcc
...
...
@@ -13,19 +13,23 @@ module Projects
def
restore
json
=
IO
.
read
(
@path
)
tree_hash
=
ActiveSupport
::
JSON
.
decode
(
json
)
project_params
=
tree_hash
.
reject
{
|
_key
,
value
|
value
.
is_a?
(
Array
)
}
project
=
Projects
::
ImportExport
::
ProjectFactory
.
create
(
project_params:
project_params
,
user:
@user
)
project
.
save
relation_hash
=
{}
project
=
create_project
(
tree_hash
)
ImportExport
.
project_tree
.
each
do
|
relation
|
next
if
tree_hash
[
relation
.
to_s
].
empty?
relation_hash
[
relation
.
to_s
]
=
create_relation
(
relation
,
tree_hash
[
relation
.
to_s
],
project
.
id
)
project
.
update_attribute
(
relation
,
relation_hash
[
relation
.
to_s
]
)
relation_hash
=
create_relation
(
relation
,
tree_hash
[
relation
.
to_s
],
project
.
id
)
project
.
update_attribute
(
relation
,
relation_hash
)
end
end
private
def
create_project
(
tree_hash
)
project_params
=
tree_hash
.
reject
{
|
_key
,
value
|
value
.
is_a?
(
Array
)
}
project
=
Projects
::
ImportExport
::
ProjectFactory
.
create
(
project_params:
project_params
,
user:
@user
)
project
.
save
project
end
def
create_relation
(
relation
,
relation_hash_list
,
project_id
)
relation_hash_list
.
map
do
|
relation_hash
|
Projects
::
ImportExport
::
RelationFactory
.
create
(
...
...
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