def update_answer_in_index(sender, instance, **kw): # raw is True when saving a model exactly as presented--like when # loading fixtures. In this case we don't want to trigger. if not settings.ES_LIVE_INDEXING or kw.get('raw'): return es_utils.add_index_task(index_questions.delay, (instance.question_id,))
def update_document_from_index(sender, instance, **kw): # raw is True when saving a model exactly as presented--like when # loading fixtures. In this case we don't want to trigger. if not settings.ES_LIVE_INDEXING or kw.get('raw'): return from wiki.tasks import index_documents es_utils.add_index_task(index_documents.delay, (instance.id, ))
def update_post_in_index(sender, instance, **kw): # raw is True when saving a model exactly as presented--like when # loading fixtures. In this case we don't want to trigger. if not settings.ES_LIVE_INDEXING or kw.get('raw'): return from forums.tasks import index_threads es_utils.add_index_task(index_threads.delay, (instance.thread_id,))
def update_answervote_in_index(sender, instance, **kw): # TODO: We only need to update the helpful bit. It's possible # we could ignore all AnswerVotes that aren't helpful and if # they're marked as helpful, then update the index. Look into # this. # raw is True when saving a model exactly as presented--like when # loading fixtures. In this case we don't want to trigger. if not settings.ES_LIVE_INDEXING or kw.get('raw'): return es_utils.add_index_task(index_questions.delay, ( instance.answer.question_id,))
def test_tasks(self): """Tests to make sure tasks are added and run""" times_run = [] def run_task(*args): times_run.append(1) es_utils.add_index_task(run_task, (1,)) eq_(len(times_run), 0) es_utils.generate_tasks() eq_(len(times_run), 1)
def test_tasks(self): """Tests to make sure tasks are added and run""" times_run = [] def run_task(*args): times_run.append(1) es_utils.add_index_task(run_task, (1, )) eq_(len(times_run), 0) es_utils.generate_tasks() eq_(len(times_run), 1)
def remove_answervote_from_index(sender, instance, **kw): if not settings.ES_LIVE_INDEXING: return es_utils.add_index_task(index_questions.delay, ( instance.answer.question_id,))
def remove_post_from_index(sender, instance, **kw): if not settings.ES_LIVE_INDEXING: return from forums.tasks import index_threads es_utils.add_index_task(index_threads.delay, (instance.thread_id,))