Пример #1
0
    def promote(self):
        from kuma.wiki.tasks import index_documents

        # Index all outdated documents to this index.
        outdated_ids = []
        for outdated_object in self.outdated_objects.all():
            instance = outdated_object.content_object
            outdated_ids.append(instance.id)
        if outdated_ids:
            index_documents.delay(outdated_ids, self.pk)
        # Clear outdated.
        self.outdated_objects.all().delete()
        # Promote this index.
        self.promoted = True
        self.save()
        # Allow only a single index to be promoted.
        Index.objects.exclude(pk=self.pk).update(promoted=False)
Пример #2
0
    def promote(self):
        from kuma.wiki.tasks import index_documents

        # Index all outdated documents to this index.
        outdated_ids = []
        for outdated_object in self.outdated_objects.all():
            instance = outdated_object.content_object
            outdated_ids.append(instance.id)
        if outdated_ids:
            index_documents.delay(outdated_ids, self.pk)
        # Clear outdated.
        self.outdated_objects.all().delete()
        # Promote this index.
        self.promoted = True
        self.save()
        # Allow only a single index to be promoted.
        Index.objects.exclude(pk=self.pk).update(promoted=False)
Пример #3
0
def render_done_handler(instance, **kwargs):
    if not settings.ES_LIVE_INDEX:
        return

    doc = instance
    if WikiDocumentType.should_update(doc):
        current_index = Index.objects.get_current()
        outdated = current_index.record_outdated(doc)
        if outdated:
            log.info('Found a newer index and scheduled '
                     'indexing it after promotion.')
        doc_pks = set([item.pk for item in doc.other_translations])
        doc_pks.add(doc.id)
        try:
            index_documents.delay(list(doc_pks), current_index.pk)
        except Exception:
            log.error('Search indexing task failed', exc_info=True)
    else:
        log.info('Ignoring wiki document %r while updating search index',
                 doc.id, exc_info=True)
Пример #4
0
def render_done_handler(instance, **kwargs):
    if not settings.ES_LIVE_INDEX:
        return

    doc = instance
    if WikiDocumentType.should_update(doc):
        current_index = Index.objects.get_current()
        outdated = current_index.record_outdated(doc)
        if outdated:
            log.info('Found a newer index and scheduled '
                     'indexing it after promotion.')
        doc_pks = {item.pk for item in doc.other_translations}
        doc_pks.add(doc.id)
        try:
            index_documents.delay(list(doc_pks), current_index.pk)
        except Exception:
            log.error('Search indexing task failed', exc_info=True)
    else:
        log.info('Ignoring wiki document %r while updating search index',
                 doc.id,
                 exc_info=True)
Пример #5
0
def render_done_handler(**kwargs):
    if not settings.ES_LIVE_INDEX or 'instance' not in kwargs:
        return

    from kuma.wiki.tasks import index_documents
    from .models import Index

    doc = kwargs['instance']
    if WikiDocumentType.should_update(doc):
        current_index = Index.objects.get_current()
        outdated = current_index.record_outdated(doc)
        if outdated:
            log.info('Found a newer index and scheduled '
                     'indexing it after promotion.')
        doc_pks = set(doc.other_translations.values_list('pk', flat=True))
        doc_pks.add(doc.id)
        try:
            index_documents.delay(list(doc_pks), current_index.pk)
        except:
            log.error('Search indexing task failed', exc_info=True)
    else:
        log.info('Ignoring wiki document %r while updating search index',
                 doc.id, exc_info=True)