2018-07-17 12:50:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-06 11:23:49 -04:00
|
|
|
module Projects
|
|
|
|
class BaseMoveRelationsService < BaseService
|
|
|
|
attr_reader :source_project
|
|
|
|
def execute(source_project, remove_remaining_elements: true)
|
|
|
|
return if source_project.blank?
|
|
|
|
|
|
|
|
@source_project = source_project
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-04-06 11:23:49 -04:00
|
|
|
def prepare_relation(relation, id_param = :id)
|
|
|
|
if Gitlab::Database.postgresql?
|
|
|
|
relation
|
|
|
|
else
|
|
|
|
relation.model.where("#{id_param}": relation.pluck(id_param))
|
|
|
|
end
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-04-06 11:23:49 -04:00
|
|
|
end
|
|
|
|
end
|