Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Tekst-API/tekst/resources/text_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,14 @@ async def _update_aggregations(

async def _ensure_token_ids(self):
"""Checks if all tokens have a token_id annotation, and if not, adds one"""
contents_changed = False
text_slug = None
alphabet = string.ascii_lowercase + string.ascii_uppercase + string.digits
content_doc_model = TextAnnotation.content_model().document_model()

async for content in ContentBaseDocument.find(
Eq(ContentBaseDocument.resource_id, self.id),
Eq(content_doc_model.tokens.id, None),
with_children=True,
):
dirty = False
Expand All @@ -515,6 +519,10 @@ async def _ensure_token_ids(self):
dirty = True
if dirty:
await content.save()
contents_changed = True

if contents_changed:
await self.contents_changed_hook()

async def resource_precompute_hook(
self,
Expand Down