-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
chore: Refactor UpdateSuperUserMigrationHelperCE for re-use in EE #36851
Conversation
WalkthroughThe changes in this pull request involve modifications to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/solutions/ce/UpdateSuperUserMigrationHelperCE.java (3 hunks)
🧰 Additional context used
🔇 Additional comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/solutions/ce/UpdateSuperUserMigrationHelperCE.java (2)
11-11
: Excellent Use of Nullability AnnotationIt's great to see the import of
org.jetbrains.annotations.NotNull
. Using@NotNull
helps prevent null-related errors and improves code reliability. Keep up the good work ensuring your methods clearly communicate their nullability contracts!
Line range hint
70-80
: Ensure User's Username is Not NullWhen constructing the permission group name using
user.getUsername()
, ensure that the username is not null to avoid a potentialNullPointerException
. It's advisable to add a null check or use a default value ifuser.getUsername()
might be null.Would you like to add a null check for the user's username, or should we enforce that the username must be set before this method is called?
PermissionGroup userManagementPermissionGroup = createUserManagementPermissionGroup(mongoTemplate, user); | ||
|
||
Set<Policy> userPolicies = this.generateUserPolicy( | ||
user, userManagementPermissionGroup, instanceAdminRole, tenant, policySolution, policyGenerator); | ||
|
||
user.setPolicies(userPolicies); | ||
|
||
return mongoTemplate.save(user); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Optimize by Reducing Multiple Database Saves
I notice that you're saving the User
object twice in the createNewUser
method: once after initial creation and again after setting the policies. To improve efficiency, consider setting all user properties, including policies, before the initial save. This way, you can minimize database interactions and enhance performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me.
Automation
/ok-to-test tags="@tag.Sanity"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11321563633
Commit: 402dfb3
Cypress dashboard.
Tags:
@tag.Sanity
Spec:
Mon, 14 Oct 2024 06:12:25 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
New Features
Bug Fixes