Commit 66259a01 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '38232-complete-elasticsearch-tracking-refactor' into 'master'

Complete elasticsearch tracking refactor

Closes #38232

See merge request gitlab-org/gitlab!25554
parents 312aa401 0c9302ec
......@@ -5,10 +5,9 @@ module EE
extend ActiveSupport::Concern
prepended do
# Ensure changes to project visibility settings go to elasticsearch
after_commit on: :update do
if project.use_elasticsearch?
ElasticIndexerWorker.perform_async(:update, 'Project', project_id, project.es_id)
end
project.maintain_elasticsearch_update if project.maintaining_elasticsearch?
end
end
end
......
......@@ -23,21 +23,11 @@ module EE
end
override :post_update_hooks
# rubocop: disable CodeReuse/ActiveRecord
def post_update_hooks(updated_project_ids)
::Project.where(id: updated_project_ids).find_each do |project|
# TODO: Refactor out this duplication per https://gitlab.com/gitlab-org/gitlab/issues/38232
if ::Gitlab::CurrentSettings.elasticsearch_indexing? && project.searchable?
ElasticIndexerWorker.perform_async(
:update,
project.class.to_s,
project.id,
project.es_id
)
end
::Project.id_in(updated_project_ids).find_each do |project|
project.maintain_elasticsearch_update if project.maintaining_elasticsearch?
end
end
# rubocop: enable CodeReuse/ActiveRecord
def raise_ee_transfer_error(message)
raise ::Groups::TransferService::TransferError, EE_ERROR_MESSAGES[message]
......
......@@ -79,7 +79,7 @@ describe Groups::TransferService, '#execute' do
stub_ee_application_setting(elasticsearch_indexing: true)
end
it 'reindexes projects' do
it 'reindexes projects', :elastic do
project1 = create(:project, :repository, :public, namespace: group)
project2 = create(:project, :repository, :public, namespace: group)
project3 = create(:project, :repository, :private, namespace: group)
......
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