-
Notifications
You must be signed in to change notification settings - Fork 308
resolve #216
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
base: main
Are you sure you want to change the base?
resolve #216
Conversation
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.
Great job on implementing the task requirements! 🎉 The code is well-structured and meets the core functionality needed. While there are a couple of minor improvements suggested, such as optimizing the HttpClient
usage and revising the random character query for better compatibility, these do not hinder the overall functionality. Keep up the great work and consider these suggestions for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
@Query("FROM Character ORDER BY RAND() LIMIT 1") | ||
Character getRandomCharacter(); |
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.
The getRandomCharacter
method uses ORDER BY RAND() LIMIT 1
, which is not standard JPQL syntax. JPQL does not support LIMIT
or RAND()
directly. Consider using native SQL or a different approach to fetch a random record.
CharacterResponseDataDto allCharacters = new CharacterResponseDataDto(); | ||
|
||
for (int currentPage = 1; currentPage <= 42; currentPage++) { | ||
HttpClient client = HttpClient.newHttpClient(); |
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.
Creating a new HttpClient
instance inside the loop is inefficient. Consider moving HttpClient client = HttpClient.newHttpClient();
outside the loop to reuse the same client for all requests.
public CharacterDto getRandomCharacter() { | ||
return characterMapper.toDto(characterRepository.getRandomCharacter()); |
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.
The getRandomCharacter
method relies on the getRandomCharacter
query in CharacterRepository
, which uses non-standard JPQL syntax (ORDER BY RAND() LIMIT 1
). Consider revising the repository method to ensure compatibility with JPA.
No description provided.