Cleanup empty instance nodes in the same task not as a separate task
This commit is contained in:
@@ -29,13 +29,11 @@ def document_index_delete(sender, **kwargs):
|
||||
@receiver(post_save, dispatch_uid='document_metadata_index_update', sender=DocumentMetadata)
|
||||
def document_metadata_index_update(sender, **kwargs):
|
||||
task_index_document.apply_async(kwargs=dict(document_id=kwargs['instance'].document.pk), queue='indexing')
|
||||
task_delete_empty_index_nodes.apply_async(queue='indexing')
|
||||
|
||||
|
||||
@receiver(post_delete, dispatch_uid='document_metadata_index_post_delete', sender=DocumentMetadata)
|
||||
def document_metadata_index_post_delete(sender, **kwargs):
|
||||
task_index_document.apply_async(kwargs=dict(document_id=kwargs['instance'].document.pk), queue='indexing')
|
||||
task_delete_empty_index_nodes.apply_async(queue='indexing')
|
||||
|
||||
|
||||
register_maintenance_links([rebuild_index_instances], namespace='document_indexing', title=_(u'Indexes'))
|
||||
|
||||
@@ -24,6 +24,8 @@ def index_document(document):
|
||||
for index_node in IndexInstanceNode.objects.filter(documents=document):
|
||||
index_node.documents.remove(document)
|
||||
|
||||
delete_empty_index_nodes()
|
||||
|
||||
# Only update indexes where the document type is found or that do not have any document type specified
|
||||
# TODO: explicit document type selection, none != all
|
||||
for index in Index.objects.filter(Q(enabled=True) & (Q(document_types=None) | Q(document_types=document.document_type))):
|
||||
|
||||
Reference in New Issue
Block a user