summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-17 14:01:33 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-04-17 17:34:48 +0300
commit8b4b687d445236766c168a844b856d8c09efe1a2 (patch)
tree5629c26b947a5a2a0c23e43e918912f7855f6a08 /app/models
parent047dacc7001cc658031914c668111ba42ac9944e (diff)
downloadgitlab-ce-8b4b687d445236766c168a844b856d8c09efe1a2.tar.gz
Merge branch 'google-code-import-performance' into 'master'
Decrease memory use and increase performance of Google Code importer. Addresses private issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2241. See merge request !536
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project.rb8
-rw-r--r--app/models/project_import_data.rb19
2 files changed, 22 insertions, 5 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index c4f50e02ddd..64ee2c2212b 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -27,7 +27,6 @@
# import_type :string(255)
# import_source :string(255)
# avatar :string(255)
-# import_data :text
#
require 'carrierwave/orm/activerecord'
@@ -51,8 +50,6 @@ class Project < ActiveRecord::Base
default_value_for :wall_enabled, false
default_value_for :snippets_enabled, gitlab_config_features.snippets
- serialize :import_data, JSON
-
# set last_activity_at to the same as created_at
after_create :set_last_activity_at
def set_last_activity_at
@@ -117,6 +114,8 @@ class Project < ActiveRecord::Base
has_many :users_star_projects, dependent: :destroy
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 :members, to: :team, prefix: true
@@ -267,8 +266,7 @@ class Project < ActiveRecord::Base
end
def clear_import_data
- self.import_data = nil
- self.save
+ self.import_data.destroy if self.import_data
end
def import?
diff --git a/app/models/project_import_data.rb b/app/models/project_import_data.rb
new file mode 100644
index 00000000000..6a8a8a56eb5
--- /dev/null
+++ b/app/models/project_import_data.rb
@@ -0,0 +1,19 @@
+# == 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