Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect annotation reordering in document detail page (#1438) #1439

Merged
merged 2 commits into from
Aug 25, 2023

Conversation

blms
Copy link
Contributor

@blms blms commented Aug 10, 2023

In this PR

Per #1438:

  • Add order_by("content__schema:position", "created") to the annotation set in Footnote.content_html, so that reordered annotations will appear in the correct order on the document detail page

Questions

  • Since this is a cached property, I'm wondering about cache busting when annotations are reordered. It seems to work for me locally when I hard refresh the doc detail page, but wondering if that's always the case / if there's a way to do it automatically from the backend?

@codecov
Copy link

codecov bot commented Aug 10, 2023

Codecov Report

Merging #1439 (6dc44df) into develop (9dfe138) will increase coverage by 0.01%.
Report is 9 commits behind head on develop.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop    #1439      +/-   ##
===========================================
+ Coverage    98.69%   98.71%   +0.01%     
===========================================
  Files          200      201       +1     
  Lines        11102    11241     +139     
===========================================
+ Hits         10957    11096     +139     
  Misses         145      145              

@blms blms requested a review from rlskoeser August 16, 2023 19:58
Copy link
Contributor

@rlskoeser rlskoeser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update looks good to me, makes sense.

The cached property only applies to the object instance, to avoid recomputing a dynamic property multiple times for generating a page (possibly not strictly needed in this case, unless we have logic that depends on whether there is content). When you reload the page you get a new instance of the object, so this caching isn't relevant. I suspect that's why it worked for you on a reload.

@@ -606,7 +606,9 @@ def content_html(self):
# keyed on canvas uri
# handle multiple annotations on the same canvas
html_content = defaultdict(list)
for a in self.annotation_set.all():
for a in self.annotation_set.all().order_by(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth a one-line comment here documenting what this is for

I checked, default ordering is by created; makes sense we wouldn't want to rely on an optional/custom parameter for sort

@blms blms merged commit c2d49b8 into develop Aug 25, 2023
10 checks passed
@blms blms deleted the bugfix/1438-annotation-reordering branch August 25, 2023 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants