Commit 0eba75e9 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch '41587-osw-mr-metrics-migration-take-two-ee' into 'master'

[CE port] Take two for MR metrics population background migration

See merge request gitlab-org/gitlab-ee!5911
parents e01963e8 c2ef7635
......@@ -37,6 +37,15 @@ module Gitlab
new(*args).create
end
def self.relation_class(relation_name)
# There are scenarios where the model is pluralized (e.g.
# MergeRequest::Metrics), and we don't want to force it to singular
# with #classify.
relation_name.to_s.classify.constantize
rescue NameError
relation_name.to_s.constantize
end
def initialize(relation_sym:, relation_hash:, members_mapper:, user:, project:, excluded_keys: [])
@relation_name = OVERRIDES[relation_sym] || relation_sym
@relation_hash = relation_hash.except('noteable_id')
......@@ -196,7 +205,7 @@ module Gitlab
end
def relation_class
@relation_class ||= @relation_name.to_s.classify.constantize
@relation_class ||= self.class.relation_class(@relation_name)
end
def imported_object
......
......@@ -10,7 +10,7 @@ module ConfigurationHelper
def relation_class_for_name(relation_name)
relation_name = Gitlab::ImportExport::RelationFactory::OVERRIDES[relation_name.to_sym] || relation_name
relation_name.to_s.classify.constantize
Gitlab::ImportExport::RelationFactory.relation_class(relation_name)
end
def parsed_attributes(relation_name, attributes)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment