Skip to content

Commit

Permalink
Merge pull request #33825 from dimagi/hotfix/django-user-performance-…
Browse files Browse the repository at this point in the history
…improvements

Performance improvements for selecting django user
  • Loading branch information
gherceg authored Dec 1, 2023
2 parents 1b67098 + 080498b commit 232682e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion corehq/apps/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ def get_django_user(self, use_primary_db=False):
queryset = User.objects
if use_primary_db:
queryset = queryset.using(router.db_for_write(User))
return queryset.get(username__iexact=self.username)
return queryset.get(username=self.username)

def add_phone_number(self, phone_number, default=False, **kwargs):
""" Don't add phone numbers if they already exist """
Expand Down
4 changes: 2 additions & 2 deletions corehq/apps/users/user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def lazy_init(cls, couch_user, domain):
domain=domain,
defaults={
'data': raw_user_data,
'django_user': couch_user.get_django_user(),
'django_user': couch_user.get_django_user,
'profile_id': profile_id,
}
)
Expand All @@ -46,7 +46,7 @@ def save(self):
domain=self.domain,
defaults={
'data': self._local_to_user,
'django_user': self._couch_user.get_django_user(),
'django_user': self._couch_user.get_django_user,
'profile_id': self.profile_id,
},
)
Expand Down

0 comments on commit 232682e

Please sign in to comment.