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

Update custom habit implementation change #6520

Merged
merged 5 commits into from
Oct 6, 2023

Conversation

HelenSotnik
Copy link
Contributor

@HelenSotnik HelenSotnik commented Oct 5, 2023

GreenCity PR

Add ability to edit custom habits which user has created #6214

Summary Of Changes 🔥

Changed update of collections (HabitTranslations and CustomShoppingListItem).

  • for HabitTranslations update - only fields are to be updated, as translation is not necessary to apply for custom habit, during creation of new custom habit it saves the same data for 'en' language and for 'ua'.
    for CustomShoppingListItem now:
  • it saves new customShoppingListItems to CustomShoppingListItemRepo and for current habit. (this is applied if user decides to add some new customShoppingListItems to his custom habit)
  • if CustomShoppingListItem exists already in habit customShoppingListItems, so only update is applied. (used for update of existing)
  • if some of habit customShoppingListItems are absent in received dto, but they existed before, they are deleted(this applied if user decides to delete some of his customShoppingListItems in habit)

@HelenSotnik HelenSotnik changed the title Update custom habit implementstion change Update custom habit implementation change Oct 5, 2023
@@ -944,6 +905,8 @@ void updateCustomHabitWithOneParameterToUpdateTest() throws IOException {
assertEquals(customHabitDtoResponse,
habitService.updateCustomHabit(customHabitDtoRequest, 1L, "[email protected]", image));

verify(customShoppingListItemRepo, times(2)).findAllByUserIdAndHabitId(2L, 1L);
// verify(customShoppingListItemRepo).save(any());

Choose a reason for hiding this comment

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

please remove it if it is unused

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is used, I have forgotten to uncomment it, already did.

}

private void updateHabitTranslationsForCustomHabit(CustomHabitDtoRequest habitDto, Habit habit) {
HabitTranslationDto habitTranslationDto = habitDto.getHabitTranslations().get(0);

Choose a reason for hiding this comment

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

can we have indexoutofboundexception here?
please use findFirst

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.20) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

@HelenSotnik HelenSotnik merged commit 6635c2a into dev Oct 6, 2023
3 checks passed
@HelenSotnik HelenSotnik deleted the update-custom-habit-method-change branch October 6, 2023 10:33
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.

5 participants