Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-18 18:08:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-18 18:08:51 +0300
commit163a7046ac76eb4109184e82ce0af911633e6626 (patch)
tree9f22bb438db435d518e8f5520b309c6319ae0bd8 /lib/gitlab/background_migration
parent0637ba1e6e9024f35b2cbf561d9002ec17350bb3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/background_migration')
-rw-r--r--lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb3
-rw-r--r--lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb12
-rw-r--r--lib/gitlab/background_migration/user_mentions/models/design.rb32
-rw-r--r--lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb18
4 files changed, 61 insertions, 4 deletions
diff --git a/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb b/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb
index 40f45301727..22b984887b1 100644
--- a/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb
+++ b/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb
@@ -21,7 +21,8 @@ module Gitlab
records.in_groups_of(BULK_INSERT_SIZE, false).each do |records|
mentions = []
records.each do |record|
- mentions << record.build_mention_values(resource_user_mention_model.resource_foreign_key)
+ mention_record = record.build_mention_values(resource_user_mention_model.resource_foreign_key)
+ mentions << mention_record unless mention_record.blank?
end
Gitlab::Database.bulk_insert(
diff --git a/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb b/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb
index b7fa92a6686..1fac4b230ca 100644
--- a/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb
+++ b/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb
@@ -68,12 +68,18 @@ module Gitlab
def build_mention_values(resource_foreign_key)
refs = all_references(author)
+ mentioned_users_ids = array_to_sql(refs.mentioned_users.pluck(:id))
+ mentioned_projects_ids = array_to_sql(refs.mentioned_projects.pluck(:id))
+ mentioned_groups_ids = array_to_sql(refs.mentioned_groups.pluck(:id))
+
+ return if mentioned_users_ids.blank? && mentioned_projects_ids.blank? && mentioned_groups_ids.blank?
+
{
"#{resource_foreign_key}": user_mention_resource_id,
note_id: user_mention_note_id,
- mentioned_users_ids: array_to_sql(refs.mentioned_users.pluck(:id)),
- mentioned_projects_ids: array_to_sql(refs.mentioned_projects.pluck(:id)),
- mentioned_groups_ids: array_to_sql(refs.mentioned_groups.pluck(:id))
+ mentioned_users_ids: mentioned_users_ids,
+ mentioned_projects_ids: mentioned_projects_ids,
+ mentioned_groups_ids: mentioned_groups_ids
}
end
diff --git a/lib/gitlab/background_migration/user_mentions/models/design.rb b/lib/gitlab/background_migration/user_mentions/models/design.rb
new file mode 100644
index 00000000000..66cff561bcb
--- /dev/null
+++ b/lib/gitlab/background_migration/user_mentions/models/design.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+# rubocop:disable Style/Documentation
+
+module Gitlab
+ module BackgroundMigration
+ module UserMentions
+ module Models
+ module DesignManagement
+ class Design < ActiveRecord::Base
+ include MentionableMigrationMethods
+
+ def self.user_mention_model
+ Gitlab::BackgroundMigration::UserMentions::Models::DesignUserMention
+ end
+
+ def user_mention_model
+ self.class.user_mention_model
+ end
+
+ def user_mention_resource_id
+ id
+ end
+
+ def user_mention_note_id
+ 'NULL'
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb b/lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb
new file mode 100644
index 00000000000..68205ecd3c2
--- /dev/null
+++ b/lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+# rubocop:disable Style/Documentation
+
+module Gitlab
+ module BackgroundMigration
+ module UserMentions
+ module Models
+ class DesignUserMention < ActiveRecord::Base
+ self.table_name = 'design_user_mentions'
+
+ def self.resource_foreign_key
+ :design_id
+ end
+ end
+ end
+ end
+ end
+end