Skip to content

Commit

Permalink
[Fix #4409] Disable autoindexing in local development
Browse files Browse the repository at this point in the history
  • Loading branch information
safwanrahman committed Jul 27, 2018
1 parent db51a90 commit ebcbcb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions readthedocs/search/signals.py
Expand Up @@ -2,6 +2,7 @@
from __future__ import absolute_import
import django.dispatch
from django.dispatch import receiver
from django_elasticsearch_dsl.apps import DEDConfig
from django_elasticsearch_dsl.registries import registry

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

index_objects_to_es_task(**kwargs)
# Do not index if autosync is disabled globally
if DEDConfig.autosync_enabled():
index_objects_to_es_task(**kwargs)


@receiver(bulk_post_delete, sender=HTMLFile)
def remove_html_file(instance_list, **_):
registry.delete(instance_list)
# Do not index if autosync is disabled globally
if DEDConfig.autosync_enabled():
registry.delete(instance_list)
3 changes: 3 additions & 0 deletions readthedocs/settings/dev.py
Expand Up @@ -48,6 +48,9 @@ def DATABASES(self): # noqa
'test:8000',
)

# Disable auto syncing elasticsearch documents in development
ELASTICSEARCH_DSL_AUTOSYNC = False

@property
def LOGGING(self): # noqa - avoid pep8 N802
logging = super(CommunityDevSettings, self).LOGGING
Expand Down

0 comments on commit ebcbcb9

Please sign in to comment.