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: improve manytoone relations in db (no link tables) #98

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from

Conversation

BettyB979
Copy link
Contributor

No description provided.

@BettyB979
Copy link
Contributor Author

BettyB979 commented Dec 11, 2024

  • Removal of unnecessary relationship tables from the database (correction of @manytoone and OneToMany relationships)

  • Optimisation of search endpoints

  • Script:

DROP TABLE public.campaign_partitionings;

DROP TABLE public.contact_contact_events;

DROP TABLE public.internal_users_user_events;

DROP TABLE public.operator_service_operators;

DROP TABLE public.questioning_questioning_accreditations;

DROP TABLE public.questioning_questioning_comments;

DROP TABLE public.questioning_questioning_communications;

DROP TABLE public.questioning_questioning_events;

DROP TABLE public.source_source_accreditations;

DROP TABLE public.source_surveys;

DROP TABLE public.survey_campaigns;

DROP TABLE public.survey_unit_questionings;

DROP TABLE public.survey_unit_survey_unit_comments;

CREATE INDEX idx_contact_fullname_upper
ON contact (upper(first_name || ' ' || last_name));


return updateContactAddressEvent(contact, payload);

} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

else antipattern ;)

newContact.setAddress(addressService.convertToEntity(contactDto.getAddress()));
}

Contact createdContact = createContactAddressEvent(newContact, payload);
Copy link
Contributor

Choose a reason for hiding this comment

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

createContactAddressEvent creates a contact, but the method name indicates we create an address event

Contact createdContact = createContactAddressEvent(newContact, payload);

// Créer une vue pour le nouveau contact
viewService.createView(id, null, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

refactoring name to understand we're talking about contacts ? Why not using a real view instead of a table ?

@@ -32,35 +31,14 @@ public Owner insertOrUpdateOwner(Owner owner) {

try {
Owner ownerBase = findById(owner.getId());
Copy link
Contributor

Choose a reason for hiding this comment

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

findById could return an Optional, you won't need the try/catch in this case. The save method could be after the try/catch

pageQuestionings = questioningRepository.findBySurveyUnitIdSuOrSurveyUnitIdentificationCodeOrQuestioningAccreditationsIdContact(param, param, param, pageable);
List<Questioning> listQuestionings = questioningRepository.findQuestioningByParam(param.toUpperCase());
List<SearchQuestioningDto> searchDtos = listQuestionings
.stream().distinct()
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe the distinct could be in the sql query ?

.stream().distinct()
.map(this::convertToSearchDto).toList();

return new PageImpl<>(searchDtos, pageable, searchDtos.size());
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

else anti pattern

@BettyB979 BettyB979 marked this pull request as ready for review December 17, 2024 10:15
@davdarras
Copy link
Contributor

could be great to create migration scripts for database

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