Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/2.7' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Mar 12, 2024
2 parents d0e4e9c + bdaad19 commit b627ea6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
# and https://github.com/psf/requests/pull/5651)
"urllib3<1.26",
"eve>=1.1.2,<=2.1.0",
"eve-elastic>=7.3.2,<7.4.0",
"eve-elastic>=7.4.0,<7.5.0",
"elasticsearch<7.14", # we are using oss version on test server
"flask>=1.1,<1.2",
"flask-mail>=0.9,<0.10",
"flask-script>=2.0.5,<3.0",
Expand Down
14 changes: 6 additions & 8 deletions superdesk/commands/rebuild_elastic_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@


import superdesk
import elasticsearch

from flask import current_app
from eve_elastic import get_es, get_indices, reindex
from superdesk.utils import get_random_string
from flask import current_app as app


class RebuildElasticIndex(superdesk.Command):
Expand All @@ -33,18 +30,19 @@ class RebuildElasticIndex(superdesk.Command):
"""

option_list = [
superdesk.Option('--resource', '-r', dest='resource_name')
superdesk.Option('--resource', '-r', dest='resource_name'),
superdesk.Option('--requests-per-second', dest='requests_per_second'),
]

def run(self, resource_name=None):
def run(self, resource_name=None, requests_per_second=1000):
# if no index name is passed then use the configured one
resources = list(current_app.data.elastic._get_elastic_resources().keys())
resources = list(app.data.elastic._get_elastic_resources().keys())
if resource_name and resource_name in resources:
resources = [resource_name]
elif resource_name:
raise ValueError("Resource {} is not configured".format(resource_name))
for resource in resources:
current_app.data.elastic.reindex(resource)
app.data.elastic.reindex(resource, requests_per_second=requests_per_second)
print('Index {} rebuilt successfully.'.format(resource))


Expand Down
5 changes: 3 additions & 2 deletions superdesk/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,9 @@ def setup(context=None, config=None, app_factory=get_app, reset=False):
if context:
context.app = app
context.client = app.test_client()
if not hasattr(context, "BEHAVE"):
app.test_request_context().push()
if not hasattr(context, "BEHAVE") and not hasattr(context, "test_context"):
context.test_context = app.test_request_context()
context.test_context.push()

with app.app_context():
clean_dbs(app, force=bool(config))
Expand Down

0 comments on commit b627ea6

Please sign in to comment.