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

app ready #46

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

app ready #46

wants to merge 2 commits into from

Conversation

ItsUnbidden
Copy link

No description provided.

Copy link

@kerrrusha kerrrusha left a comment

Choose a reason for hiding this comment

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

very good job, can be improved a little

implementationPackage = "<PACKAGE_NAME>.impl"
)
public class MapperConfig {

Choose a reason for hiding this comment

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

Suggested change

Copy link
Author

@ItsUnbidden ItsUnbidden Nov 7, 2023

Choose a reason for hiding this comment

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

I'm not entirely sure what you meant here and in the other similar reviews.

Choose a reason for hiding this comment

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

redundant blank lines

@RequiredArgsConstructor
public class AppStartupRunner implements ApplicationRunner {
private final CharacterRepository repository;

Choose a reason for hiding this comment

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

Suggested change


@Override
public void run(ApplicationArguments args) throws Exception {
if (characterClient.getDataByPage(1).getInfo().getCount() != repository.count()) {

Choose a reason for hiding this comment

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

is it up-to-date data check? consider extracting it to self-explanatory named method

Suggested change
if (characterClient.getDataByPage(1).getInfo().getCount() != repository.count()) {
if (characterClient.getDataByPage(1).getInfo().getCount() != repository.count()) {

Comment on lines 21 to 28
if (characterClient.getDataByPage(1).getInfo().getCount() != repository.count()) {
List<Character> allCharacters = characterClient.getAllCharacters();
for (Character character : allCharacters) {
if (!repository.findByExternalId(character.getExternalId()).isPresent()) {
repository.save(character);
}
}
}

Choose a reason for hiding this comment

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

all this logic can be separated to the DataLoader service (too low abstraction on high-level ApplicationRunner)

}
}
}
System.out.println(characterClient.getDataByPage(1));

Choose a reason for hiding this comment

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

what's purpose of this log? better do debug, also we have @Slf4j logger embed in Lombok

Suggested change
System.out.println(characterClient.getDataByPage(1));
log.debug(characterClient.getDataByPage(1));

private static final String BASE_URL = "https://rickandmortyapi.com/api/character/?page=%s";

private final ObjectMapper objectMapper;

Choose a reason for hiding this comment

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

Suggested change

}

public CharacterResponseDataDto getDataByPage(int page) {
HttpClient client = HttpClient.newHttpClient();

Choose a reason for hiding this comment

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

as we are using Spring, consider creating @Bean public HttpClient httpClient()... bean in your Spring Configuration, so we could autowire it to the private final class-level field


@Override
public CharacterDto getRandomCharacter() {
Random random = new Random();

Choose a reason for hiding this comment

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

should be class-level field, injected by Spring

@RequiredArgsConstructor
public class CharacterServiceImpl implements CharacterService {
private final CharacterRepository characterRepository;

Choose a reason for hiding this comment

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

Suggested change

@@ -19,8 +19,45 @@
<maven.checkstyle.plugin.configLocation>

Choose a reason for hiding this comment

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

miss-clicked approve (:

@ItsUnbidden
Copy link
Author

I didn't quite understand some problems you pointed out. The ones with the -. Would be great if you clarified.

@ItsUnbidden ItsUnbidden requested a review from kerrrusha November 7, 2023 14:29
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