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

Make `%aunique` work with `-f/--format` options. #3043

Merged
merged 3 commits into from Sep 27, 2018

Conversation

Projects
None yet
2 participants
@djl
Copy link
Member

commented Sep 27, 2018

This should fix #3042. Let's see if Travis gives the thumbs up...

djl added some commits Sep 25, 2018

@sampsyo
Copy link
Member

left a comment

Looks great! Thank you!! Here’s one small comment.

@@ -1395,6 +1395,8 @@ def get_album(self, item_or_id):
"""
if isinstance(item_or_id, int):
album_id = item_or_id
elif isinstance(item_or_id, Album):
album_id = item_or_id.id

This comment has been minimized.

Copy link
@sampsyo

sampsyo Sep 27, 2018

Member

If this function can now accept Album objects, maybe we should update the docstring to reflect that? (Also, I don’t quite see where the call is that makes this change necessary—maybe that call should be rewritten to just use the Album object it already has instead of going to the database to get another identical copy?)

This comment has been minimized.

Copy link
@djl

djl Sep 27, 2018

Author Member

The call to lib.get_album() comes from tmpl_aunique where self.item can be either an Item or an Album.

I couldn't think of a clean way of refactoring that method. I suppose lib.get_album(), if given an Album, could just return the same object. That would prevent hitting the database twice.

This comment has been minimized.

Copy link
@sampsyo

sampsyo Sep 27, 2018

Member

How about using lib.get_album(album_id)? In your improved version of tmpl_aunique, we now have an album_id variable already. That won't prevent hitting the database twice, but it will avoid expanding the responsibilities of get_album.

This comment has been minimized.

Copy link
@djl

djl Sep 27, 2018

Author Member

Good idea! Pushed a new commit.

@sampsyo

This comment has been minimized.

Copy link
Member

commented Sep 27, 2018

Awesome. Looks perfect. 🎉 🚀 🐭

@sampsyo sampsyo merged commit 54cf6d4 into master Sep 27, 2018

4 checks passed

continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@arcresu arcresu deleted the aunique-format branch Apr 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.