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

Change user methods to work with authorId #617

Merged
merged 17 commits into from
Nov 1, 2023

Conversation

VadimasikKPI
Copy link
Contributor

develop

GitHub Board

Issue link

#11 Issue name

Story link

#11 Story

Code reviewers

  • @github_username

Summary of issue

  • Summary of issue
  • Summary of issue

Summary of change

  • Summary of change
  • Summary of change

@@ -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();
Copy link
Contributor

@handicraftsman handicraftsman Nov 1, 2023

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.

Voloshkevych and others added 10 commits November 1, 2023 13:14
* 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
Copy link
Contributor

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.

@VadimasikKPI VadimasikKPI merged commit 12688c5 into develop Nov 1, 2023
1 check passed
VadimasikKPI added a commit that referenced this pull request Nov 1, 2023
* 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]>
VadimasikKPI added a commit that referenced this pull request Nov 17, 2023
* 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]>
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.

3 participants