Skip to content

Commit 612cfb8

Browse files
committed
[Fix #4409] Disable autoindexing in local development
1 parent db51a90 commit 612cfb8

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

readthedocs/search/signals.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import absolute_import
33
import django.dispatch
44
from django.dispatch import receiver
5+
from django_elasticsearch_dsl.apps import DEDConfig
56
from django_elasticsearch_dsl.registries import registry
67

78
from readthedocs.projects.models import HTMLFile
@@ -20,13 +21,17 @@ def index_html_file(instance_list, **_):
2021
'app_label': HTMLFile._meta.app_label,
2122
'model_name': HTMLFile.__name__,
2223
'document_class': str(PageDocument),
23-
'index_name': None, # No neeed to change the index name
24+
'index_name': None, # No need to change the index name
2425
'objects_id': [obj.id for obj in instance_list],
2526
}
2627

27-
index_objects_to_es_task(**kwargs)
28+
# Do not index if autosync is disabled globally
29+
if DEDConfig.autosync_enabled():
30+
index_objects_to_es_task(**kwargs)
2831

2932

3033
@receiver(bulk_post_delete, sender=HTMLFile)
3134
def remove_html_file(instance_list, **_):
32-
registry.delete(instance_list)
35+
# Do not index if autosync is disabled globally
36+
if DEDConfig.autosync_enabled():
37+
registry.delete(instance_list)

readthedocs/settings/dev.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def DATABASES(self): # noqa
4848
'test:8000',
4949
)
5050

51+
# Disable auto syncing elasticsearch documents in development
52+
ELASTICSEARCH_DSL_AUTOSYNC = False
53+
5154
@property
5255
def LOGGING(self): # noqa - avoid pep8 N802
5356
logging = super(CommunityDevSettings, self).LOGGING

readthedocs/settings/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CommunityTestSettings(CommunityDevSettings):
1717
DEBUG = False
1818
TEMPLATE_DEBUG = False
1919
ES_PAGE_IGNORE_SIGNALS = False
20+
ELASTICSEARCH_DSL_AUTOSYNC = True
2021

2122
@property
2223
def ES_INDEXES(self): # noqa - avoid pep8 N802

0 commit comments

Comments
 (0)