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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
38982136
Commit
38982136
authored
Apr 17, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decrease memory use and increase performance of Google Code importer.
parent
7d98c884
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
47 deletions
+38
-47
lib/gitlab/google_code_import/importer.rb
lib/gitlab/google_code_import/importer.rb
+38
-47
No files found.
lib/gitlab/google_code_import/importer.rb
View file @
38982136
...
@@ -62,24 +62,7 @@ module Gitlab
...
@@ -62,24 +62,7 @@ module Gitlab
def
import_issues
def
import_issues
return
unless
repo
.
issues
return
unless
repo
.
issues
last_id
=
0
while
raw_issue
=
repo
.
issues
.
shift
deleted_issues
=
[]
repo
.
issues
.
each
do
|
raw_issue
|
while
raw_issue
[
"id"
]
>
last_id
+
1
last_id
+=
1
issue
=
project
.
issues
.
create!
(
title:
"Deleted issue"
,
description:
"*This issue has been deleted*"
,
author_id:
project
.
creator_id
,
state:
"closed"
)
deleted_issues
<<
issue
end
last_id
=
raw_issue
[
"id"
]
author
=
user_map
[
raw_issue
[
"author"
][
"name"
]]
author
=
user_map
[
raw_issue
[
"author"
][
"name"
]]
date
=
DateTime
.
parse
(
raw_issue
[
"published"
]).
to_formatted_s
(
:long
)
date
=
DateTime
.
parse
(
raw_issue
[
"published"
]).
to_formatted_s
(
:long
)
...
@@ -116,7 +99,8 @@ module Gitlab
...
@@ -116,7 +99,8 @@ module Gitlab
end
end
end
end
issue
=
project
.
issues
.
create!
(
issue
=
Issue
.
create!
(
project_id:
project
.
id
,
title:
raw_issue
[
"title"
],
title:
raw_issue
[
"title"
],
description:
body
,
description:
body
,
author_id:
project
.
creator_id
,
author_id:
project
.
creator_id
,
...
@@ -125,39 +109,46 @@ module Gitlab
...
@@ -125,39 +109,46 @@ module Gitlab
)
)
issue
.
add_labels_by_names
(
labels
)
issue
.
add_labels_by_names
(
labels
)
if
issue
.
iid
!=
raw_issue
[
"id"
]
issue
.
update_attribute
(
:iid
,
raw_issue
[
"id"
])
end
import_issue_comments
(
issue
,
comments
)
import_issue_comments
(
issue
,
comments
)
end
end
deleted_issues
.
each
(
&
:destroy!
)
end
end
def
import_issue_comments
(
issue
,
comments
)
def
import_issue_comments
(
issue
,
comments
)
comments
.
each
do
|
raw_comment
|
Note
.
transaction
do
next
if
raw_comment
.
has_key?
(
"deletedBy"
)
while
raw_comment
=
comments
.
shift
next
if
raw_comment
.
has_key?
(
"deletedBy"
)
content
=
format_content
(
raw_comment
[
"content"
])
updates
=
format_updates
(
raw_comment
[
"updates"
])
content
=
format_content
(
raw_comment
[
"content"
])
attachments
=
format_attachments
(
issue
.
iid
,
raw_comment
[
"id"
],
raw_comment
[
"attachments"
])
updates
=
format_updates
(
raw_comment
[
"updates"
])
attachments
=
format_attachments
(
issue
.
iid
,
raw_comment
[
"id"
],
raw_comment
[
"attachments"
])
next
if
content
.
blank?
&&
updates
.
blank?
&&
attachments
.
blank?
next
if
content
.
blank?
&&
updates
.
blank?
&&
attachments
.
blank?
author
=
user_map
[
raw_comment
[
"author"
][
"name"
]]
date
=
DateTime
.
parse
(
raw_comment
[
"published"
]).
to_formatted_s
(
:long
)
author
=
user_map
[
raw_comment
[
"author"
][
"name"
]]
date
=
DateTime
.
parse
(
raw_comment
[
"published"
]).
to_formatted_s
(
:long
)
body
=
format_issue_comment_body
(
raw_comment
[
"id"
],
body
=
format_issue_comment_body
(
author
,
raw_comment
[
"id"
],
date
,
author
,
content
,
date
,
updates
,
content
,
attachments
updates
,
)
attachments
)
issue
.
notes
.
create!
(
# Needs to match order of `comment_columns` below.
project_id:
project
.
id
,
Note
.
create!
(
author_id:
project
.
creator_id
,
project_id:
project
.
id
,
note:
body
noteable_type:
"Issue"
,
)
noteable_id:
issue
.
id
,
author_id:
project
.
creator_id
,
note:
body
)
end
end
end
end
end
...
@@ -236,7 +227,7 @@ module Gitlab
...
@@ -236,7 +227,7 @@ module Gitlab
def
create_label
(
name
)
def
create_label
(
name
)
color
=
nice_label_color
(
name
)
color
=
nice_label_color
(
name
)
project
.
labels
.
create!
(
name:
name
,
color:
color
)
Label
.
create!
(
project_id:
project
.
id
,
name:
name
,
color:
color
)
end
end
def
format_content
(
raw_content
)
def
format_content
(
raw_content
)
...
...
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