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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
7d98c884
Commit
7d98c884
authored
Apr 17, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move import data out of project so it doesn't take ages to load.
parent
dfebcb89
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
30 deletions
+63
-30
app/models/project.rb
app/models/project.rb
+3
-5
app/models/project_import_data.rb
app/models/project_import_data.rb
+19
-0
db/migrate/20150417121913_create_project_import_data.rb
db/migrate/20150417121913_create_project_import_data.rb
+8
-0
db/migrate/20150417122318_remove_import_data_from_project.rb
db/migrate/20150417122318_remove_import_data_from_project.rb
+5
-0
db/schema.rb
db/schema.rb
+6
-2
lib/gitlab/google_code_import/importer.rb
lib/gitlab/google_code_import/importer.rb
+7
-3
lib/gitlab/google_code_import/project_creator.rb
lib/gitlab/google_code_import/project_creator.rb
+10
-19
spec/lib/gitlab/google_code_import/importer_spec.rb
spec/lib/gitlab/google_code_import/importer_spec.rb
+5
-1
No files found.
app/models/project.rb
View file @
7d98c884
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
# import_type :string(255)
# import_type :string(255)
# import_source :string(255)
# import_source :string(255)
# avatar :string(255)
# avatar :string(255)
# import_data :text
#
#
require
'carrierwave/orm/activerecord'
require
'carrierwave/orm/activerecord'
...
@@ -51,8 +50,6 @@ class Project < ActiveRecord::Base
...
@@ -51,8 +50,6 @@ class Project < ActiveRecord::Base
default_value_for
:wall_enabled
,
false
default_value_for
:wall_enabled
,
false
default_value_for
:snippets_enabled
,
gitlab_config_features
.
snippets
default_value_for
:snippets_enabled
,
gitlab_config_features
.
snippets
serialize
:import_data
,
JSON
# set last_activity_at to the same as created_at
# set last_activity_at to the same as created_at
after_create
:set_last_activity_at
after_create
:set_last_activity_at
def
set_last_activity_at
def
set_last_activity_at
...
@@ -117,6 +114,8 @@ class Project < ActiveRecord::Base
...
@@ -117,6 +114,8 @@ class Project < ActiveRecord::Base
has_many
:users_star_projects
,
dependent: :destroy
has_many
:users_star_projects
,
dependent: :destroy
has_many
:starrers
,
through: :users_star_projects
,
source: :user
has_many
:starrers
,
through: :users_star_projects
,
source: :user
has_one
:import_data
,
dependent: :destroy
,
class_name:
"ProjectImportData"
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
delegate
:members
,
to: :team
,
prefix:
true
delegate
:members
,
to: :team
,
prefix:
true
...
@@ -267,8 +266,7 @@ class Project < ActiveRecord::Base
...
@@ -267,8 +266,7 @@ class Project < ActiveRecord::Base
end
end
def
clear_import_data
def
clear_import_data
self
.
import_data
=
nil
self
.
import_data
.
destroy
if
self
.
import_data
self
.
save
end
end
def
import?
def
import?
...
...
app/models/project_import_data.rb
0 → 100644
View file @
7d98c884
# == Schema Information
#
# Table name: project_import_datas
#
# id :integer not null, primary key
# project_id :integer
# data :text
#
require
'carrierwave/orm/activerecord'
require
'file_size_validator'
class
ProjectImportData
<
ActiveRecord
::
Base
belongs_to
:project
serialize
:data
,
JSON
validates
:project
,
presence:
true
end
db/migrate/20150417121913_create_project_import_data.rb
0 → 100644
View file @
7d98c884
class
CreateProjectImportData
<
ActiveRecord
::
Migration
def
change
create_table
:project_import_data
do
|
t
|
t
.
references
:project
t
.
text
:data
end
end
end
db/migrate/20150417122318_remove_import_data_from_project.rb
0 → 100644
View file @
7d98c884
class
RemoveImportDataFromProject
<
ActiveRecord
::
Migration
def
change
remove_column
:projects
,
:import_data
end
end
db/schema.rb
View file @
7d98c884
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2015041
3192223
)
do
ActiveRecord
::
Schema
.
define
(
version:
2015041
7122318
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -323,6 +323,11 @@ ActiveRecord::Schema.define(version: 20150413192223) do
...
@@ -323,6 +323,11 @@ ActiveRecord::Schema.define(version: 20150413192223) do
add_index
"oauth_applications"
,
[
"owner_id"
,
"owner_type"
],
name:
"index_oauth_applications_on_owner_id_and_owner_type"
,
using: :btree
add_index
"oauth_applications"
,
[
"owner_id"
,
"owner_type"
],
name:
"index_oauth_applications_on_owner_id_and_owner_type"
,
using: :btree
add_index
"oauth_applications"
,
[
"uid"
],
name:
"index_oauth_applications_on_uid"
,
unique:
true
,
using: :btree
add_index
"oauth_applications"
,
[
"uid"
],
name:
"index_oauth_applications_on_uid"
,
unique:
true
,
using: :btree
create_table
"project_import_data"
,
force:
true
do
|
t
|
t
.
integer
"project_id"
t
.
text
"data"
end
create_table
"projects"
,
force:
true
do
|
t
|
create_table
"projects"
,
force:
true
do
|
t
|
t
.
string
"name"
t
.
string
"name"
t
.
string
"path"
t
.
string
"path"
...
@@ -348,7 +353,6 @@ ActiveRecord::Schema.define(version: 20150413192223) do
...
@@ -348,7 +353,6 @@ ActiveRecord::Schema.define(version: 20150413192223) do
t
.
integer
"star_count"
,
default:
0
,
null:
false
t
.
integer
"star_count"
,
default:
0
,
null:
false
t
.
string
"import_type"
t
.
string
"import_type"
t
.
string
"import_source"
t
.
string
"import_source"
t
.
text
"import_data"
end
end
add_index
"projects"
,
[
"created_at"
,
"id"
],
name:
"index_projects_on_created_at_and_id"
,
using: :btree
add_index
"projects"
,
[
"created_at"
,
"id"
],
name:
"index_projects_on_created_at_and_id"
,
using: :btree
...
...
lib/gitlab/google_code_import/importer.rb
View file @
7d98c884
...
@@ -5,7 +5,10 @@ module Gitlab
...
@@ -5,7 +5,10 @@ module Gitlab
def
initialize
(
project
)
def
initialize
(
project
)
@project
=
project
@project
=
project
@repo
=
GoogleCodeImport
::
Repository
.
new
(
project
.
import_data
[
"repo"
])
import_data
=
project
.
import_data
.
try
(
:data
)
repo_data
=
import_data
[
"repo"
]
if
import_data
@repo
=
GoogleCodeImport
::
Repository
.
new
(
repo_data
)
@closed_statuses
=
[]
@closed_statuses
=
[]
@known_labels
=
Set
.
new
@known_labels
=
Set
.
new
...
@@ -27,9 +30,10 @@ module Gitlab
...
@@ -27,9 +30,10 @@ module Gitlab
def
user_map
def
user_map
@user_map
||=
begin
@user_map
||=
begin
user_map
=
Hash
.
new
{
|
hash
,
user
|
hash
[
user
]
=
Client
.
mask_email
(
user
)
}
user_map
=
Hash
.
new
{
|
hash
,
user
|
Client
.
mask_email
(
user
)
}
stored_user_map
=
project
.
import_data
[
"user_map"
]
import_data
=
project
.
import_data
.
try
(
:data
)
stored_user_map
=
import_data
[
"user_map"
]
if
import_data
user_map
.
update
(
stored_user_map
)
if
stored_user_map
user_map
.
update
(
stored_user_map
)
if
stored_user_map
user_map
user_map
...
...
lib/gitlab/google_code_import/project_creator.rb
View file @
7d98c884
...
@@ -11,12 +11,7 @@ module Gitlab
...
@@ -11,12 +11,7 @@ module Gitlab
end
end
def
execute
def
execute
import_data
=
{
project
=
::
Projects
::
CreateService
.
new
(
current_user
,
"repo"
=>
repo
.
raw_data
,
"user_map"
=>
user_map
}
@project
=
Project
.
new
(
name:
repo
.
name
,
name:
repo
.
name
,
path:
repo
.
name
,
path:
repo
.
name
,
description:
repo
.
summary
,
description:
repo
.
summary
,
...
@@ -25,21 +20,17 @@ module Gitlab
...
@@ -25,21 +20,17 @@ module Gitlab
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
,
import_type:
"google_code"
,
import_type:
"google_code"
,
import_source:
repo
.
name
,
import_source:
repo
.
name
,
import_url:
repo
.
import_url
,
import_url:
repo
.
import_url
import_data:
import_data
).
execute
)
if
@project
.
save!
@project
.
reload
if
@project
.
import_failed?
import_data
=
project
.
create_import_data
(
@project
.
import_retry
data:
{
else
"repo"
=>
repo
.
raw_data
,
@project
.
import_start
"user_map"
=>
user_map
end
}
end
)
@
project
project
end
end
end
end
end
end
...
...
spec/lib/gitlab/google_code_import/importer_spec.rb
View file @
7d98c884
...
@@ -12,9 +12,13 @@ describe Gitlab::GoogleCodeImport::Importer do
...
@@ -12,9 +12,13 @@ describe Gitlab::GoogleCodeImport::Importer do
}
}
}
}
}
}
let
(
:project
)
{
create
(
:project
,
import_data:
import_data
)
}
let
(
:project
)
{
create
(
:project
)
}
subject
{
described_class
.
new
(
project
)
}
subject
{
described_class
.
new
(
project
)
}
before
do
project
.
create_import_data
(
data:
import_data
)
end
describe
"#execute"
do
describe
"#execute"
do
it
"imports status labels"
do
it
"imports status labels"
do
...
...
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