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

added solution #148

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

Serhii-Nosulia
Copy link

No description provided.


@Bean
public ObjectMapper buildObjectMapper() {

Choose a reason for hiding this comment

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

Suggested change

public List<CharacterResponseDto> searchCharactersByName(@RequestParam String name) {
return characterService.findAllByName(name);
}
}

Choose a reason for hiding this comment

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

Suggested change
}
}

Comment on lines 7 to 9
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ThirdApiCharacterResponseDto {

Choose a reason for hiding this comment

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

having single DTO as class while others are records look strange

CharacterResponseDataDto.class);
characterResponseDataDto.results().stream()
.map(characterMapper::toCharacter)
.forEach(characterRepository::save);

Choose a reason for hiding this comment

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

check if possible to use saveAll method to reduce amount of DB calls

Comment on lines 24 to 27
@PostConstruct
public void loadDataToDb() {
rickAndMortyClient.loadDataToDb();
}

Choose a reason for hiding this comment

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

This method doesn't look like it should be here

Suggested change
@PostConstruct
public void loadDataToDb() {
rickAndMortyClient.loadDataToDb();
}

private final ObjectMapper objectMapper;
private final HttpClient httpClient;

public void loadDataToDb() {

Choose a reason for hiding this comment

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

Probably just

Suggested change
public void loadDataToDb() {
@PostConstruct
public void loadDataToDb() {

Comment on lines 31 to 32
long count = characterRepository.count();
Character character = characterRepository.findById(random.nextLong(count))

Choose a reason for hiding this comment

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

Please check possibility to get single random record by using SQL query. It may you allow to fully get rid of Random object and simplify code

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