forked from 0x2620/pandora
Entity.save(): update annotations async (fixes #2827, kinda)
This commit is contained in:
parent
41b50ccdb8
commit
ace04688f2
2 changed files with 18 additions and 10 deletions
|
@ -123,3 +123,19 @@ def update_item(id, force=False):
|
||||||
a.item.update_facets()
|
a.item.update_facets()
|
||||||
if a.item.update_languages():
|
if a.item.update_languages():
|
||||||
a.item.save()
|
a.item.save()
|
||||||
|
|
||||||
|
|
||||||
|
@task(ignore_results=True, queue='default')
|
||||||
|
def update_annotations(layers, value):
|
||||||
|
items = {}
|
||||||
|
|
||||||
|
with transaction.commit_on_success():
|
||||||
|
for a in models.Annotation.objects.filter(
|
||||||
|
layer__in=layers,
|
||||||
|
value=value
|
||||||
|
):
|
||||||
|
a.save()
|
||||||
|
items[a.item.id] = a.id
|
||||||
|
|
||||||
|
for id in items.values():
|
||||||
|
update_item.delay(id, True)
|
||||||
|
|
|
@ -234,16 +234,8 @@ class Entity(models.Model):
|
||||||
|
|
||||||
entity_layers = [l['id'] for l in settings.CONFIG['layers'] if l['type'] == 'entity']
|
entity_layers = [l['id'] for l in settings.CONFIG['layers'] if l['type'] == 'entity']
|
||||||
if entity_layers:
|
if entity_layers:
|
||||||
with transaction.commit_on_success():
|
annotation.tasks.update_annotations.delay(entity_layers, self.get_id())
|
||||||
items = {}
|
|
||||||
for a in annotation.models.Annotation.objects.filter(
|
|
||||||
layer__in=entity_layers,
|
|
||||||
value=self.get_id()
|
|
||||||
):
|
|
||||||
a.save()
|
|
||||||
items[a.item.id] = a.id
|
|
||||||
for id in items.values():
|
|
||||||
annotation.tasks.update_item.delay(id, True)
|
|
||||||
|
|
||||||
class DocumentProperties(models.Model):
|
class DocumentProperties(models.Model):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue