Skip to content

Commit

Permalink
fix RebuildElasticIndex command to try async resource first
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkLark86 committed Nov 11, 2024
1 parent 194f10e commit db82f25
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions superdesk/commands/rebuild_elastic_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ def run(self, resource_name=None, requests_per_second=1000):
async_app = get_current_async_app()
app = async_app.wsgi
resources = list(app.data.elastic._get_elastic_resources().keys())
if resource_name and resource_name in resources:
async_resource_configs = async_app.resources.get_all_configs()
async_resources = {config.name for config in async_resource_configs}
if resource_name and (resource_name in resources or resource_name in async_resources):
resources = [resource_name]
elif resource_name:
raise ValueError("Resource {} is not configured".format(resource_name))

resources_processed = []
for config in async_app.resources.get_all_configs():
for config in async_resource_configs:
if config.elastic is None:
continue
async_app.elastic.reindex(config.name, requests_per_second=requests_per_second)
Expand Down

0 comments on commit db82f25

Please sign in to comment.