-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #430 from ox-it/index-list-names-1919
Index list names - task #1919
- Loading branch information
Showing
9 changed files
with
94 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
FROM solr | ||
FROM makuk66/docker-solr:4.10.4 | ||
|
||
ADD ./talks/conf/schema.xml /opt/solr/example/solr/collection1/conf/schema.xml | ||
ADD ./talks/conf/solrconfig.xml /opt/solr/example/solr/collection1/conf/solrconfig.xml | ||
ADD ./talks/conf/stopwords.txt /opt/solr/example/solr/collection1/conf/stopwords.txt | ||
ADD ./talks/conf/lang /opt/solr/example/solr/collection1/conf/lang/ | ||
|
||
# CMD ["/bin/bash", "-c", "cd /opt/solr/example; java -jar start.jar"] | ||
|
||
EXPOSE 8983 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Custom signal processor for event changes | ||
# If an event is saved, upate it in the default way. | ||
# If a list is saved, update affected events | ||
|
||
from talks.events.models import Event | ||
from talks.users.models import Collection, CollectionItem | ||
from django.db import models | ||
from haystack import signals | ||
from haystack.exceptions import NotHandled | ||
|
||
class EventUpdateSignalProcessor(signals.BaseSignalProcessor): | ||
def setup(self): | ||
# connect event save/delete to default handler | ||
models.signals.post_save.connect(self.handle_save, sender=Event) | ||
models.signals.post_delete.connect(self.handle_delete, sender=Event) | ||
|
||
# connect list save to handler for collection | ||
models.signals.post_save.connect(self.handle_save_list, sender=Collection) | ||
# removing a list treated same as updating it - we just update the affected talks | ||
models.signals.post_delete.connect(self.handle_save_list, sender=Collection) | ||
|
||
# update when talk is added/removed from a collection | ||
models.signals.post_save.connect(self.handle_change_collectionItem, sender=CollectionItem) | ||
models.signals.post_delete.connect(self.handle_change_collectionItem, sender=CollectionItem) | ||
|
||
def teardown(self): | ||
# disconnect event/collection save/delete | ||
models.signals.post_save.disconnect(self.handle_save, sender=Event) | ||
models.signals.post_delete.disconnect(self.handle_delete, sender=Event) | ||
models.signals.post_save.disconnect(self.handle_save_list, sender=Collection) | ||
models.signals.post_delete.disconnect(self.handle_save_list, sender=Collection) | ||
models.signals.post_save.disconnect(self.handle_change_collectionItem, sender=CollectionItem) | ||
models.signals.post_delete.disconnect(self.handle_change_collectionItem, sender=CollectionItem) | ||
|
||
def handle_save_list(self, sender, instance, **kwargs): | ||
# update the each event from the list in each index | ||
events = instance.get_all_events() | ||
using_backends = self.connection_router.for_write(instance=instance) | ||
|
||
for event in events.all(): | ||
for using in using_backends: | ||
try: | ||
index = self.connections[using].get_unified_index().get_index(event.__class__) | ||
index.update_object(event, using=using) | ||
except Exception: | ||
# TODO: Maybe log it or let the exception bubble? | ||
print "NOT HANDLED" | ||
pass | ||
|
||
def handle_change_collectionItem(self, sender, instance, **kwargs): | ||
#re-index the affected event | ||
item = instance.item | ||
|
||
using_backends = self.connection_router.for_write(instance=instance) | ||
|
||
|
||
for using in using_backends: | ||
try: | ||
index = self.connections[using].get_unified_index().get_index(item.__class__) | ||
index.update_object(item, using=using) | ||
except Exception: | ||
print "NOT HANDLED" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters