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

Bug fixes after 634 #623

Merged
merged 37 commits into from
Nov 17, 2023
Merged

Bug fixes after 634 #623

merged 37 commits into from
Nov 17, 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

VitaliiKulinskyi and others added 30 commits July 2, 2021 14:59
fields for user, response statuses
VadimasikKPI and others added 5 commits November 1, 2023 19:47
* 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 <fhghvhg314@gmail.com>
Co-authored-by: Voloshkevych <59647995+Voloshkevych@users.noreply.github.com>

---------

Co-authored-by: VadimasikKPI <fhghvhg314@gmail.com>
Co-authored-by: Voloshkevych <59647995+Voloshkevych@users.noreply.github.com>
Copy link
Collaborator

@V-Kaidash V-Kaidash left a comment

Choose a reason for hiding this comment

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

Hey there!
Overall looks good. Dropped a few comments on some improvements. Please check if it's feasible to implement.
Thanks)

+ "U.phone, U.created_at, U.avatar,U.enabled,U.role_id, U.edited_at, "
+ "U.public_email, D.author_id as \"user_id\" from USERS U\n"
+ "JOIN AUTHORS D ON U.user_id=D.user_id")
value = "SELECT U.* from USERS U\n")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
value = "SELECT U.* from USERS U\n")
value = "SELECT U.* from USERS U")

@@ -97,7 +97,11 @@ public Page<UserEntity> findAll(Pageable pageable) {
*/
@Override
public UserDTO findExpertById(Integer userId) {
return userMapper.toUserDTO(userRepository.findById(userId).orElse(null));
AuthorEntity author = authorRepository.findById(userId).orElse(null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
AuthorEntity author = authorRepository.findById(userId).orElse(null);
AuthorEntity author = authorRepository.findById(userId).orElseThrow(() -> new EntityNotFoundException("Author not found"));;

And you can remove if-statement.
This is a more concise way to achieve the same outcome.

if (author == null) {
throw new EntityNotFoundException("Author not found");
}
return userMapper.toUserDTO(userRepository.findById(author.getProfile().getId()).orElse(null));
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not a good practice to return null value. Try to avoid such cases if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it good to also throw EntityNotFoundException in this case like in previous one to avoid null returning?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's definitely better than returning null.

Copy link
Collaborator

@V-Kaidash V-Kaidash left a comment

Choose a reason for hiding this comment

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

Good job! :)

@VadimasikKPI VadimasikKPI merged commit 4583169 into develop Nov 17, 2023
1 check passed
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.

9 participants