Skip to content
代码片段 群组 项目
未验证 提交 47ebff88 编辑于 作者: Terri Chu's avatar Terri Chu 提交者: GitLab
浏览文件

Fix index namespaces for indexing subgroup associations

上级 340149a2
No related branches found
No related tags found
无相关合并请求
......@@ -314,7 +314,6 @@ def index_users
def index_namespaces
Namespace.by_parent(nil).each_batch do |batch|
batch = batch.include_route
batch = batch.select(&:use_elasticsearch?)
ElasticNamespaceIndexerWorker.bulk_perform_async_with_contexts(
batch,
......
......@@ -23,7 +23,6 @@ def perform(namespace_id, operation)
case operation.to_s
when /index/
index_projects(namespace)
index_group_wikis(namespace) if should_maintain_group_wiki_index?(namespace)
index_group_associations(namespace)
when /delete/
delete_from_index(namespace)
......@@ -47,7 +46,14 @@ def index_group_wikis(namespace)
end
def index_group_associations(namespace)
Elastic::ProcessBookkeepingService.maintain_indexed_namespace_associations!(namespace)
namespace.self_and_descendants.each_batch do |batch|
Elastic::ProcessBookkeepingService.maintain_indexed_namespace_associations!(*batch)
batch.group_namespaces.each.with_index do |namespace, idx|
interval = idx % ElasticWikiIndexerWorker::MAX_JOBS_PER_HOUR
ElasticWikiIndexerWorker.perform_in(interval, namespace.id, namespace.class.name, { 'force' => true })
end
end
end
def delete_from_index(namespace)
......
......@@ -27,8 +27,8 @@
end
describe 'indexing and deleting', :elastic_helpers do
let_it_be(:namespace) { create :namespace }
let_it_be(:projects) { create_list :project, 3, namespace: namespace }
let_it_be(:namespace) { create(:namespace) }
let_it_be(:projects) { create_list(:project, 3, namespace: namespace) }
context 'for :index' do
it_behaves_like 'an idempotent worker' do
......@@ -99,7 +99,7 @@
it 'calls Elastic::ProcessBookkeepingService.maintain_indexed_namespace_associations!' do
expect(Elastic::ProcessBookkeepingService).to receive(:maintain_indexed_namespace_associations!)
.with(*parent_group).once
.with(parent_group, sub_group, sub_child_group).once
worker.perform(*job_args)
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册