-
Notifications
You must be signed in to change notification settings - Fork 240
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
base: main
Are you sure you want to change the base?
added solution #148
Conversation
|
||
@Bean | ||
public ObjectMapper buildObjectMapper() { | ||
|
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.
public List<CharacterResponseDto> searchCharactersByName(@RequestParam String name) { | ||
return characterService.findAllByName(name); | ||
} | ||
} |
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.
} | |
} | |
@Data | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class ThirdApiCharacterResponseDto { |
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.
having single DTO as class while others are records look strange
CharacterResponseDataDto.class); | ||
characterResponseDataDto.results().stream() | ||
.map(characterMapper::toCharacter) | ||
.forEach(characterRepository::save); |
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.
check if possible to use saveAll method to reduce amount of DB calls
@PostConstruct | ||
public void loadDataToDb() { | ||
rickAndMortyClient.loadDataToDb(); | ||
} |
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.
This method doesn't look like it should be here
@PostConstruct | |
public void loadDataToDb() { | |
rickAndMortyClient.loadDataToDb(); | |
} |
private final ObjectMapper objectMapper; | ||
private final HttpClient httpClient; | ||
|
||
public void loadDataToDb() { |
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.
Probably just
public void loadDataToDb() { | |
@PostConstruct | |
public void loadDataToDb() { |
long count = characterRepository.count(); | ||
Character character = characterRepository.findById(random.nextLong(count)) |
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.
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
No description provided.