Skip to content

Conversation

DankevichMisha
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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! ✨

Comment on lines +14 to +15
@Query("FROM Character ORDER BY RAND() LIMIT 1")
Character getRandomCharacter();

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();

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.

Comment on lines +19 to +20
public CharacterDto getRandomCharacter() {
return characterMapper.toDto(characterRepository.getRandomCharacter());

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.

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.

2 participants