Skip to content
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

Performance improvements for selecting django user #33825

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you say a bit about how you determined that this change was safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at #33824 and feel free to ask any questions there.


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
Loading