-
Notifications
You must be signed in to change notification settings - Fork 11
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
Change user methods to work with authorId #617
Conversation
… userEntity from authorEntity, change some dtos
@@ -112,31 +118,76 @@ public UserDTO findExpertById(Integer userId) { | |||
public Page<UserDTO> findAllExperts(UserSearchCriteria userSearchCriteria, Pageable pageable) { | |||
|
|||
if (validateParameters(userSearchCriteria, HAS_NO_DIRECTIONS, HAS_NO_REGIONS, HAS_NO_USERNAME)) { | |||
return userRepository.findAll(pageable).map(userMapper::toUserDTO); | |||
Page<UserDTO> userDTOS = userRepository.findAll(pageable).map(userMapper::toUserDTO); | |||
List<AuthorEntity> authors = authorRepository.findAll(); |
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.
It would work initially, but ideally this should be done on the database (SQL) side.
Yes, it will probably be a somewhat big JOIN, but it will still be faster than fetching all the authors to only use some of them.
Additionally, you can do something like this:
@Query("SELECT ... FROM ... WHERE profileId IN (:userIds)") // Might need to do a JOIN here, I do not remember the database structure. That will still be faster though.
List<Author> getAuthorsByUserIds(Set<String> userIds);
You should then convert the authors list to a map using Java streams.
Finding authors using that will be much faster than iterating through authors list again and again.
Same is for all the similar blocks below.
* Refactored deleteById method * Fixed style errors * Tests are ready to go * Refactored deleteById method * Fixed style errors * Tests are ready to go * Added eventPublisher for deleteById method * Added method to change status
… userEntity from authorEntity, change some dtos
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.
Can be rewritten in a shorter way using mapstruct and JPA queries, but I suggested @VadimasikKPI doing that in a follow-up pull request after he reads more on mapstruct.
* Implement user account activation logic without tests, they will be in next commits * Return port 5432 to docker compose file * Made changes regarding comments * Made changes regarding comments * Delete rewrite (#616) * Refactored deleteById method * Fixed style errors * Tests are ready to go * Refactored deleteById method * Fixed style errors * Tests are ready to go * Added eventPublisher for deleteById method * Added method to change status * Change user methods to work with authorId (#617) * Change everywhere we use userId to AuthorId and then add logic to get userEntity from authorEntity, change some dtos * Change tests to new version of code * Change tests to new version of code * Change tests to new version of code * test * test * test * Delete rewrite (#616) * Refactored deleteById method * Fixed style errors * Tests are ready to go * Refactored deleteById method * Fixed style errors * Tests are ready to go * Added eventPublisher for deleteById method * Added method to change status * Change everywhere we use userId to AuthorId and then add logic to get userEntity from authorEntity, change some dtos * Change tests to new version of code * Change tests to new version of code * Change tests to new version of code * test * test * test * Add join author id to all queries that returns user information --------- Co-authored-by: VadimasikKPI <[email protected]> Co-authored-by: Voloshkevych <[email protected]> --------- Co-authored-by: VadimasikKPI <[email protected]> Co-authored-by: Voloshkevych <[email protected]>
* Update develop.md * Update master.md * Add dokazovi.info into allowed_origin * Merge 634 user story and delete logic (#618) * Implement user account activation logic without tests, they will be in next commits * Return port 5432 to docker compose file * Made changes regarding comments * Made changes regarding comments * Delete rewrite (#616) * Refactored deleteById method * Fixed style errors * Tests are ready to go * Refactored deleteById method * Fixed style errors * Tests are ready to go * Added eventPublisher for deleteById method * Added method to change status * Change user methods to work with authorId (#617) * Change everywhere we use userId to AuthorId and then add logic to get userEntity from authorEntity, change some dtos * Change tests to new version of code * Change tests to new version of code * Change tests to new version of code * test * test * test * Delete rewrite (#616) * Refactored deleteById method * Fixed style errors * Tests are ready to go * Refactored deleteById method * Fixed style errors * Tests are ready to go * Added eventPublisher for deleteById method * Added method to change status * Change everywhere we use userId to AuthorId and then add logic to get userEntity from authorEntity, change some dtos * Change tests to new version of code * Change tests to new version of code * Change tests to new version of code * test * test * test * Add join author id to all queries that returns user information --------- Co-authored-by: VadimasikKPI <[email protected]> Co-authored-by: Voloshkevych <[email protected]> --------- Co-authored-by: VadimasikKPI <[email protected]> Co-authored-by: Voloshkevych <[email protected]> * bug fixes * make changes according to coments * make changes according to coments --------- Co-authored-by: Vitalii Kulinskyi <[email protected]> Co-authored-by: AxelNordov <[email protected]> Co-authored-by: Stanislav Kucher <[email protected]> Co-authored-by: Ihor Zakharko <[email protected]> Co-authored-by: Vlad Kaidash <[email protected]> Co-authored-by: Anton Sidliar <[email protected]> Co-authored-by: Artem Kurovskyi <[email protected]> Co-authored-by: vasilpetrus <[email protected]> Co-authored-by: VadimasikKPI <[email protected]> Co-authored-by: Voloshkevych <[email protected]>
develop
GitHub Board
Issue link
#11 Issue name
Story link
#11 Story
Code reviewers
Summary of issue
Summary of change