Mercurial > public > sg101
diff gpp/forums/search_indexes.py @ 469:3b30286adba5
Smarter search index updating for forums. This work is for #227.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 17 Aug 2011 01:02:08 +0000 |
parents | b910cc1460c8 |
children | d9b6c4ec1977 |
line wrap: on
line diff
--- a/gpp/forums/search_indexes.py Sun Aug 07 03:38:42 2011 +0000 +++ b/gpp/forums/search_indexes.py Wed Aug 17 01:02:08 2011 +0000 @@ -1,9 +1,10 @@ """Haystack search index for the weblinks application.""" from haystack.indexes import * from haystack import site -from custom_search import CondQueuedSearchIndex +from custom_search.indexes import CondQueuedSearchIndex from forums.models import Forum, Topic, Post +from forums.signals import topic_content_update, post_content_update class TopicIndex(CondQueuedSearchIndex): @@ -17,6 +18,12 @@ def get_updated_field(self): return 'update_date' + def _setup_save(self, model): + topic_content_update.connect(self.enqueue_save) + + def _teardown_save(self, model): + topic_content_update.disconnect(self.enqueue_save) + def can_index(self, instance): return instance.forum.id in Forum.objects.public_forum_ids() @@ -33,6 +40,12 @@ def get_updated_field(self): return 'update_date' + def _setup_save(self, model): + post_content_update.connect(self.enqueue_save) + + def _teardown_save(self, model): + post_content_update.disconnect(self.enqueue_save) + def can_index(self, instance): return instance.topic.forum.id in Forum.objects.public_forum_ids()