-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
refactor account get method #11141
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
refactor account get method #11141
Conversation
| result = OpenLibraryAccount.get( | ||
| email=i.email, link=i.itemname, username=i.username | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this was probably never working as intended as it would just always check one and not the rest.
7bf1922 to
c2c48eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm! One change to make sure the behaviour is the same as it was before and to avoid some unnecessary db calls.
This is a followup to the note we put here:
https://github.com/internetarchive/openlibrary/pull/10999/files#diff-884f3a712a7e51cce625ca19060335684272f33a967702b19e66e48dbdd1be69R495
Turns out raising by default isn't probably the ideal behavior for our codebase because we call the method fairly often and expect a None to get back.
As such, I added
Changes:
.getmethod with.get_by_*methods which are better defined..getmethod, we can use.get_or_raisewhen we want to raise..get_or_raiseto accept just a value and a literal for the type of valuetest=from the get methodsPS: This refactor my seem a little silly but as I'm digging into the #11133 it's been a challenge to get a user so cleaning up this code can make that a little easier.
Technical
Testing
Screenshot
Stakeholders