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: Remove upsert in setting last release notes version #31324
Conversation
WalkthroughWalkthroughThe recent update involves modifications to how the release notes viewed version is saved in the Appsmith server application. The Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@@ -8,7 +8,7 @@ | |||
|
|||
public interface CustomUserDataRepositoryCE extends AppsmithRepository<UserData> { | |||
|
|||
Mono<Void> saveReleaseNotesViewedVersion(String userId, String version); | |||
Mono<Integer> saveReleaseNotesViewedVersion(String userId, String version); |
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.
The change in return type from Mono<Void>
to Mono<Integer>
for saveReleaseNotesViewedVersion
method is a significant improvement as it provides more informative feedback from the operation. However, it would be beneficial to add documentation to clarify what the returned Integer
represents (e.g., number of records updated or inserted).
.flatMap(userId -> repository | ||
.saveReleaseNotesViewedVersion(userId, version) | ||
.flatMap(count -> { | ||
if (count == 0) { | ||
final UserData userData = new UserData(); | ||
userData.setReleaseNotesViewedVersion(version); | ||
userData.setUserId(user.getId()); | ||
return repository.save(userData).then(); | ||
} | ||
return Mono.empty(); | ||
})) |
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.
The update to setViewedCurrentVersionReleaseNotes
introduces a conditional logic that aligns with the PR's objective, enhancing the method's functionality to handle cases where no records are updated. It's recommended to add error handling for the repository.save(userData)
operation to ensure robustness, especially in scenarios where the save operation might fail.
Instead of
upsert
, weupdate
first, which is arguably the most used operation in this context, and if that fails, then we attempt an insert.We're not expecting a performance hit, since most operations here would be an actual
update
only.Summary by CodeRabbit