Improve UPSERT for Annotations
In upsert_annotations()
in src/nacsos_data/db/crud/annotations.py
the goal is to update/insert annotations. In some circumstances, some annotations have to be deleted. However, deleting them is (atm) not straight forward:
annotations_to_delete = [
(await session.scalars(select(Annotation).filter_by(annotation_id=annotation_id))).first()
for annotation_id in ids_to_remove
]
for annotation in annotations_to_delete:
await session.delete(annotation)
Would be great to figure out a more efficient way to remove the annotations that are no longer needed.