Improves shelf page query efficiency a little
This commit is contained in:
parent
7a4c4248df
commit
2d4cec4422
2 changed files with 23 additions and 12 deletions
|
@ -13,6 +13,10 @@ from bookwyrm.utils import regex
|
|||
|
||||
def get_user_from_username(viewer, username):
|
||||
"""helper function to resolve a localname or a username to a user"""
|
||||
if viewer.localname == username:
|
||||
# that's yourself, fool
|
||||
return viewer
|
||||
|
||||
# raises 404 if the user isn't found
|
||||
try:
|
||||
return models.User.viewer_aware_objects(viewer).get(localname=username)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue