From e31dbc3012598554ee16fda84dc7308324793608 Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Tue, 19 Mar 2019 07:38:19 +0100
Subject: [PATCH] Remove notifications from reindex trigger

---
 SciPost_v1/signalprocessors.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/SciPost_v1/signalprocessors.py b/SciPost_v1/signalprocessors.py
index 733872de6..48d133d76 100644
--- a/SciPost_v1/signalprocessors.py
+++ b/SciPost_v1/signalprocessors.py
@@ -8,6 +8,7 @@ from haystack import signals
 from haystack.exceptions import NotHandled
 
 from SciPost_v1.celery import app
+from notifications.models import Notification
 from submissions.models import Submission
 
 
@@ -73,8 +74,9 @@ class AutoSearchIndexingProcessor(signals.RealtimeSignalProcessor):
                 pass
 
     def handle_save(self, sender, instance, **kwargs):
-        sender_type_id = ContentType.objects.get_for_model(sender).id
-        instance_type_id = ContentType.objects.get_for_model(instance).id
-        chain = (self.remove_objects_indexes.s(sender_type_id, instance_type_id, instance.id)
-                 | self.update_instance_indexes.s(sender_type_id, instance_type_id, instance.id))
-        chain()
+        if not isinstance(instance, Notification):
+            sender_type_id = ContentType.objects.get_for_model(sender).id
+            instance_type_id = ContentType.objects.get_for_model(instance).id
+            chain = (self.remove_objects_indexes.s(sender_type_id, instance_type_id, instance.id)
+                     | self.update_instance_indexes.s(sender_type_id, instance_type_id, instance.id))
+            chain()
-- 
GitLab