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

Fix method calls in DemographicRelationship #2

Merged
merged 5 commits into from
Nov 5, 2024

Conversation

sebastian-j-ibanez
Copy link
Collaborator

@sebastian-j-ibanez sebastian-j-ibanez commented Nov 1, 2024

Changes made

  • Changed Relationship deleted field to boolean (changed get and set methods accordingly).

Summary by Sourcery

Fix calls to setDeleted in deleteDemographicRelationship and refactor the method for better readability.

Bug Fixes:

  • Fix incorrect call to setDeleted in deleteDemographicRelationship method.

Enhancements:

  • Refactor deleteDemographicRelationship method for improved readability.

Copy link

sourcery-ai bot commented Nov 1, 2024

Reviewer's Guide by Sourcery

This PR fixes issues with the deletion flag handling in demographic relationships. The main changes involve removing an unnecessary setDeleted call during relationship creation and correcting the deletion flag setting when deleting relationships. The code also includes some structural improvements for better error handling.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Removed unnecessary initialization of deletion flag
  • Removed redundant setDeleted(Boolean.FALSE) call during relationship creation since it's not needed
src/main/java/oscar/oscarDemographic/data/DemographicRelationship.java
Fixed deletion flag setting and improved error handling
  • Changed setDeleted parameter from Boolean.TRUE to ConversionUtils.toBoolString(Boolean.TRUE)
  • Restructured if-else condition for better readability
  • Improved error handling flow with proper else clause
src/main/java/oscar/oscarDemographic/data/DemographicRelationship.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

sweep-ai bot commented Nov 1, 2024

Hey @sebastian-j-ibanez, here are examples of how you can ask me to improve this pull request:

@Sweep Fix the CI errors.
@Sweep Add unit tests for `DemographicRelationship.deleteDemographicRelationship()` that verify:
- The deleted flag is properly set when deleting an existing relationship
- Error logging occurs when attempting to delete a non-existent relationship

📖 For more information on how to use Sweep, please read our documentation.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @sebastian-j-ibanez - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Please document why the change from Boolean.TRUE to ConversionUtils.toBoolString(Boolean.TRUE) was necessary. This seems like an important behavioral change that should be explained in the PR description.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@sebastian-j-ibanez sebastian-j-ibanez changed the title fix: fix calls to setDeleted in addDemographicRelationship Fix method calls in DemographicRelationship Nov 1, 2024
@yingbull
Copy link

yingbull commented Nov 1, 2024

Are these stepping on changes that were made in Magenta/OpenOSP main, @sebastian-j-ibanez ?

@sebastian-j-ibanez sebastian-j-ibanez force-pushed the demographic-relationship-fix branch from 41af51d to cd0aaaf Compare November 1, 2024 19:03
@sebastian-j-ibanez
Copy link
Collaborator Author

I changed the deleted field to match what Magenta has (should be a boolean field).

It's good to go now.

@sebastian-j-ibanez sebastian-j-ibanez force-pushed the demographic-relationship-fix branch from cd0aaaf to 25cfc01 Compare November 1, 2024 19:15
@sebastian-j-ibanez
Copy link
Collaborator Author

sebastian-j-ibanez commented Nov 1, 2024

Had to adjust one more setDeleted call in MigrateRelationshipsToContactsHelper.java.

It's trying to do a null check for the deleted field (which is not valid, since it's a boolean now).

@sebastian-j-ibanez sebastian-j-ibanez force-pushed the demographic-relationship-fix branch from 25cfc01 to c24f87e Compare November 4, 2024 14:52
return deleted;
}

public void setDeleted(String deleted) {
Copy link

Choose a reason for hiding this comment

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

That's a pretty big change going from a boolean to a string - seems intentional. Is it from an upstream commit? Feels like a rebase issue and changing the method isn't the solution maybe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason I made this change was because upstream was using a boolean.

This is what Magenta's main, alpaca, and bullfrog has (link):

public void setDeleted(boolean deleted) {
    this.deleted = deleted;
}

@yingbull yingbull merged commit 59a011b into develop/bullfrog Nov 5, 2024
3 of 4 checks passed
@sebastian-j-ibanez sebastian-j-ibanez deleted the demographic-relationship-fix branch November 11, 2024 18:57
sebastian-j-ibanez pushed a commit that referenced this pull request Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants