Skip to content

Conversation

@RayBB
Copy link
Collaborator

@RayBB RayBB commented Aug 14, 2025

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:

  • Replace most usages of generic .get method with .get_by_* methods which are better defined.
  • Removed the .get method, we can use .get_or_raise when we want to raise.
  • Refactored .get_or_raise to accept just a value and a literal for the type of value
  • Removed the unused test= from the get methods
  • Fixed a bug on the internal audit endpoint where we weren't checking all the ways to get a user

PS: 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

Comment on lines -174 to -176
result = OpenLibraryAccount.get(
email=i.email, link=i.itemname, username=i.username
)
Copy link
Collaborator Author

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.

@RayBB RayBB moved this to I'd like to work on it in Ray's Project Aug 14, 2025
@RayBB RayBB moved this from I'd like to work on it to Waiting Review/Merge from Staff in Ray's Project Aug 14, 2025
@RayBB RayBB force-pushed the refactor/account-get-method branch from 7bf1922 to c2c48eb Compare August 14, 2025 19:41
Copy link
Collaborator

@cdrini cdrini left a 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.

@cdrini cdrini merged commit 36515d8 into master Sep 3, 2025
8 checks passed
@github-project-automation github-project-automation bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project Sep 3, 2025
@cdrini cdrini deleted the refactor/account-get-method branch September 3, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants