-
Notifications
You must be signed in to change notification settings - Fork 10
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
Registration on challenge #1696
base: rest
Are you sure you want to change the base?
Conversation
Improve your code: |
src/main/java/com/softserve/teachua/controller/UserChallengeController.java
Outdated
Show resolved
Hide resolved
@PostMapping("/admin/user-challenge/challenge/duration/registered-users") | ||
public List<UserChallengeForAdminRegisteredUser> getListRegisteredUsersByChallengeIdChallengeDurationId( | ||
@RequestBody UserChallengeForAdminGetByChallengeIdDurationId userChallenge) { | ||
return userChallengeService.getListRegisteredUsersByChallengeIdChallengeDurationId(userChallenge); |
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.
Add JavaDoc to explain what this method do and try to avoid naming like this getListRegisteredUsersByChallengeIdChallengeDurationId
false, | ||
challenge, | ||
durationEntity))); | ||
return "Успішно"; |
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.
Add more information at the response. Better create response message in corresponding controller.
@Transactional | ||
public class DurationEntityServiceImpl implements DurationEntityService { | ||
private final DurationEntityRepository durationEntityRepository; | ||
private final DtoConverter dtoConverter; |
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.
Remove this unused "dtoConverter" private field
return durationEntityRepository.findAll(); | ||
} | ||
|
||
public Set<DurationEntity> mapDurationResponseListToDurationEntity( |
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.
From my point of view, the method should be private because it used only in this class.
.orElseThrow(() -> new NotExistException( | ||
String.format(USER_CHALLENGE_STATUS_NOT_FOUND_BY_STATUS_NAME, statusName))), | ||
UserChallengeStatusGet.class); | ||
log.debug("**/getting UserChallengeStatusGet by statusName = " + statusName); |
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.
Instead of +
for concatenation string in log messages, use {}
} | ||
UserChallengeStatus userChallengeStatus = userChallengeStatusRepository.save( | ||
dtoConverter.convertToEntity(userChallengeStatusAdd, new UserChallengeStatus())); | ||
log.debug("**/adding new userChallengeStatus = " + userChallengeStatusAdd.getStatusName()); |
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.
Instead of +
for concatenation string in log messages, use {}
public UserChallengeStatusUpdate updateUserChallengeStatus(UserChallengeStatusUpdate userChallengeStatusUpdate) { | ||
UserChallengeStatus newUserChallengeStatus = getUserChallengeStatusById(userChallengeStatusUpdate.getId()); | ||
newUserChallengeStatus.setStatusName(userChallengeStatusUpdate.getStatusName()); | ||
log.debug("**/updating UserChallengeStatus by userChallengeStatusUpdate = " + newUserChallengeStatus); |
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.
Instead of +
for concatenation string in log messages, use {}
UserChallengeStatus userChallengeStatus = userChallengeStatusRepository | ||
.getUserChallengeStatusById(id) | ||
.orElseThrow(() -> new NotExistException(String.format(USER_CHALLENGE_STATUS_NOT_FOUND_BY_ID, id))); | ||
log.debug("**/getting UserChallengeStatus by id = " + id); |
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.
Instead of +
for concatenation string in log messages, use {}
UserChallengeStatus userChallengeStatus = getUserChallengeStatusById(id); | ||
try { | ||
userChallengeStatusRepository.deleteById(id); | ||
userChallengeStatusRepository.flush(); |
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.
I guess, userChallengeStatusRepository.flush();
is redundant here.
SonarCloud Quality Gate failed. |
Pull Request template
Please, go through these steps before you submit a PR.
Make sure that your PR fulfills these requirements:
a. You have done your changes in a separate branch. Branches MUST have descriptive names.
b. You have a descriptive commit message with a short title (first line).
c. You have only one commit (if not, squash them into one commit).
d.
mvn verify
doesn't throw any error. If it does, fix them first and amend your commit (git commit --amend
).After these steps, you're ready to open a pull request.
a. Your pull request MUST NOT target the
main
branch on this repository. You probably want to targetrest
instead.b. Give a descriptive title to your PR.
c. Provide a description of your changes.
d. Put
closes #XXXX
in your comment to auto-close the issue that your PR fixes (if such).PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING
Checklist:
>=75%