From 4795b0fe220e47e5dc360cdaf9193070137401a2 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Thu, 21 Mar 2019 06:07:58 +0100 Subject: [PATCH] Only reindex on specified model classes --- SciPost_v1/signalprocessors.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/SciPost_v1/signalprocessors.py b/SciPost_v1/signalprocessors.py index 49f4b5298..47e7c8ed0 100644 --- a/SciPost_v1/signalprocessors.py +++ b/SciPost_v1/signalprocessors.py @@ -8,9 +8,11 @@ from celery import shared_task from haystack import connection_router, connections, signals from haystack.exceptions import NotHandled -from SciPost_v1.celery import app -from notifications.models import Notification -from submissions.models import Submission +from commentaries.models import Commentary +from comments.models import Comment +from journals.models import Publication +from submissions.models import Submission, Report + @shared_task(name='signalprocessors.remove_object_indexes') @@ -77,8 +79,12 @@ def update_instance_indexes(sender_type_id, object_type_id, object_id): class AutoSearchIndexingProcessor(signals.RealtimeSignalProcessor): def handle_save(self, sender, instance, **kwargs): + """ + Explicitly perform haystack reindex when saving objects of class: + Submission, Report, Comment, Publication. + """ try: - if not isinstance(instance, Notification): + if isinstance(instance, [Submission, Report, Comment, Publication, Commentary]): sender_type_id = ContentType.objects.get_for_model(sender).id instance_type_id = ContentType.objects.get_for_model(instance).id chain = ( -- GitLab