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

Pet details are not updated #1752

Open
99MMRR99 opened this issue Dec 19, 2024 · 13 comments
Open

Pet details are not updated #1752

99MMRR99 opened this issue Dec 19, 2024 · 13 comments

Comments

@99MMRR99
Copy link

Example: go to first owner with pet Leo of type cat.
Click on edit pet and change the type to bird or change the name.
Click on Update pet.
The pet is not updated, even though a success message is shown.
When I analysed the code, I found that the updated pet is given to the addPet method of the owner which does not change the pet in the owner list, as the pet is not new.
In PetController:
grafik

@smnk107
Copy link

smnk107 commented Dec 19, 2024

Hey !
I would like to work on this issue. Could you please assign it to me?

@99MMRR99
Copy link
Author

It seems that I cannot assign anybody to the issue, I dont know why, but feel free to fix the issue.

@smnk107
Copy link

smnk107 commented Dec 19, 2024

Okey !

@smnk107
Copy link

smnk107 commented Dec 20, 2024

Hello !
I have submitted a PR for this issue. Please review it when you have the time. Let me know if further improvements are needed. Thanks!

@99MMRR99
Copy link
Author

The solution is good and solves the problem. I would only suggest to put the whole logic with the for loop into a new method in the Owner (maybe call it updatePet). And I am not sure why you renamed the PetController to privatePetController.
Otherwise good work, thank you for fixing it!

@smnk107
Copy link

smnk107 commented Dec 22, 2024

Okey...sure ! I will correct the things.

@smnk107
Copy link

smnk107 commented Dec 22, 2024

I have created a new PR. Please review it !

@abdurraffaysyed
Copy link

abdurraffaysyed commented Dec 27, 2024

@smnk107
Thank you for your contribution! The PR looks great and is in good shape overall. I have one suggestion: it's a good practice to avoid leaving commented-out code in the codebase. Removing the commented code in the "PetController" class would help maintain a cleaner code state. Let me know if you have any questions about this!

@smnk107
Copy link

smnk107 commented Dec 28, 2024

Thanks for checking this out. I have removed the commented code. Please review it when you have the time. Let me know if further improvements are needed. Thanks!

@abdurraffaysyed
Copy link

Hi @smnk107,

Thank you for the recent changes! The PR looks great overall, and I appreciate your work on the updatePet() implementation in the Owner class. Upon reviewing the code again, I noticed that the function iterates over the pets list and compares each Pet object with the updated pet object using the pet_Id.

To make the implementation cleaner and more efficient, I suggest leveraging the existing getPet(Integer id) method within the updatePet() function. By doing so, you can directly retrieve the relevant Pet object and replace it with the updated version, avoiding the need for a loop.

This adjustment would enhance code readability and reduce potential overhead. Once this change has been incorporated, I’ll be happy to approve the PR. Please let me know if you need any assistance with the update.

Thank you again for your contribution!

VishantOwO added a commit to VishantOwO/spring-petclinic that referenced this issue Dec 31, 2024
… or name wasn't persisting - Updated processUpdateForm to modify existing pet instead of adding new one - Added proper handling of existing pet update Fixes spring-projects#1752
@smnk107
Copy link

smnk107 commented Jan 1, 2025

Dear @abdurraffaysyed

Thank you for reviewing the PR and for your constructive feedback! I appreciate the suggestion to use the getPet(Integer id) method within the updatePet() function to streamline the implementation. It’s a great idea, and I agree that it will enhance the code's readability and efficiency.

I’ve incorporated the changes. Please let me know if there’s anything else you’d like me to address. Looking forward to your review and approval!

Thanks again for your guidance and support!

@abdurraffaysyed
Copy link

@smnk107

Thank you for addressing my feedback and incorporating the suggested changes into your pull request. I have reviewed and approved your PR.

Looking forward to seeing more contributions from you in the future.
Excellent work!

@smnk107
Copy link

smnk107 commented Jan 2, 2025

@abdurraffaysyed @99MMRR99

Thank you for reviewing and approving my pull request! This was my first open-source contribution, and your feedback and support have made it an amazing experience. I'm excited to continue contributing and learning!

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

No branches or pull requests

3 participants