Skip to content

Commit

Permalink
Simplify query
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandenburgh committed Nov 6, 2023
1 parent df5e356 commit 5cb05e6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions dandiapi/api/views/dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,11 @@ def users(self, request, dandiset__pk):

def get_user_or_400(username):
try:
return User.objects.alias(
social_account_username=Subquery(
SocialAccount.objects.filter(user_id=OuterRef('id')).values(
'extra_data__login'
)[:1]
)
).get(social_account_username=username)
return (
SocialAccount.objects.select_related('user')
.get(extra_data__login=username)
.user
)
except ObjectDoesNotExist:
try:
return User.objects.get(username=username)
Expand Down

0 comments on commit 5cb05e6

Please sign in to comment.