Release 0.66.11#3325
Closed
odlbot wants to merge 10 commits into
Closed
Conversation
* feat: Welcome to learn email
* fix: update metadata for video pages --------- Co-authored-by: Ahtesham Quraish <ahtesham.quraish@192.168.1.22>
* revised desktop styles * language select margin * mobile styles * fix border radius on mobile * don't display program controls container if it shouldn't be there * proper box shadow for new contract header * fix mobile gap between header title and subtitle * fix program header font size
* feat: add course content outline section on course pages
… video collection page (#3316) * fix: change the video detail page route --------- Co-authored-by: Ahtesham Quraish <ahtesham.quraish@A006-01455.local>
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
Comment on lines
+36
to
+46
| user, created = User.objects.get_or_create(email=email, defaults=defaults) | ||
|
|
||
| profile_api.ensure_profile(user, profile_data=profile_data) | ||
| if created: | ||
| transaction.on_commit( | ||
| lambda: user_created_actions( | ||
| user=user, | ||
| is_new=True, | ||
| details=profile_data or {}, | ||
| ) | ||
| ) |
There was a problem hiding this comment.
Bug: The create_user function calls ensure_profile twice for new users: once directly and again via an on_commit hook, causing a redundant database write.
Severity: LOW
Suggested Fix
Remove the direct, synchronous call to profile_api.ensure_profile(user, profile_data=profile_data) from the create_user function. The profile creation should be handled exclusively by the on_commit hook (user_created_actions) to ensure it is only called once after the user is successfully saved to the database.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: authentication/api.py#L36-L46
Potential issue: When a new user is created via the `create_user` function, the
`ensure_profile` function is invoked twice. The first call happens synchronously within
the function body. The second call is triggered asynchronously after the database
transaction commits, via an `on_commit` hook that executes `user_created_actions`. While
the `ensure_profile` function is idempotent due to its use of `update_or_create`, this
redundant call results in an unnecessary database write operation (a create followed by
an update) for every new user. This is a logic error that introduces inefficiency.
Also affects:
profiles/plugins.py:12~21profiles/api.py:13~22
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Anastasia Beglova
Ahtesham Quraish
Zaman Afzal
Carey P Gumaer
Matt Bertrand