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

Add shelves column in shelf table #2562

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

joachimesque
Copy link
Contributor

Closes #2484

<td data-title="{% trans "Shelves" %}">
{% spaceless %}
{% for shelf in shelves %}
{% if shelf in book.shelves.all %}
Copy link
Member

Choose a reason for hiding this comment

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

I think book.shelves will produce all shelves for all users, rather than the shelf related to the current user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that it only displays the shelves for the user (see screenshot below: same book on different shelves for different users). Is there another way to test what book.shelves produces?

image

Copy link
Member

Choose a reason for hiding this comment

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

Oh, we're actually both sort of right -- book.shelves.all does produce all shelves for all users, but because it's checking if a Shelf object is present, and a Shelf is tied to a user, it still displays correctly, so this does work exactly how you intended.

My new qualm is that on a large instance, that's going to be a costly lookup, since there are a lot of shelves. It may be that assigning book.shelves.all to a variable using {% set ... %}, so that the query is only called once rather than once per shelf, will be enough mitigation?

@jaschaurbach
Copy link
Member

@joachimesque Are you still there and have resources to take a look at the review?

@joachimesque
Copy link
Contributor Author

joachimesque commented Apr 17, 2023 via email

@jaschaurbach
Copy link
Member

@joachimesque All good, thanks for letting us know and all the best!

@joachimesque
Copy link
Contributor Author

@mouse-reeve @jaschaurbach The PR is open for another look :)

@joachimesque
Copy link
Contributor Author

joachimesque commented Aug 2, 2023 via email

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.

Add "Shelf" column in book list
3 participants