Skip to content

Commit

Permalink
Annotation retrieval: fix modified-since condition to include removal
Browse files Browse the repository at this point in the history
Some front-end services like the Neuron Name Service keep track when
they last updated (meta-)annotations and on a refresh() they ask the
back-end to only return results when the annotations changed since the
last update. The back-end SQL implementation of this wasn't working
correctly: it didn't take into account the removal of annotations and
meta-annotations. This is fixed now by also looking at changes in the
past using the history tables. With this in place, the modified-since
check works as expected and e.g. the Neuron Name Service in the
front-end will refresh names correctly when an annotation is removed.

Fixes #2237
  • Loading branch information
tomka committed Oct 14, 2022
1 parent 68cb600 commit 1e7077c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions django/applications/catmaid/control/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -3599,8 +3599,11 @@ def get_annotation_info(project_id, skeleton_ids, with_annotation_names, metaann

if cond_skeleton_ids:
if metaannotations:
# Look at current data and history to see if there has been a recent
# change. We need to look at the history to see annotation removals
# too.
meta_join = """
JOIN class_instance_class_instance cici_meta_ann
JOIN class_instance_class_instance__with_history cici_meta_ann
ON cici_meta_ann.class_instance_a = cici_ann.class_instance_b
"""
meta_where = """
Expand All @@ -3611,12 +3614,14 @@ def get_annotation_info(project_id, skeleton_ids, with_annotation_names, metaann
meta_join = ''
meta_where = ''

# Look at current data and history to see if there has been a recent
# change. We need to look at the history to see annotation removals too.
extra_skeletons = f"""
UNION ALL
SELECT cici.class_instance_a, cici.class_instance_b
FROM class_instance_class_instance cici
JOIN class_instance_class_instance cici_ann
JOIN class_instance_class_instance__with_history cici_ann
ON cici_ann.class_instance_a = cici.class_instance_b
{meta_join}
Expand Down

0 comments on commit 1e7077c

Please sign in to comment.