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

Jv rick and morty impl #194

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

Conversation

mkazarian-1
Copy link

No description provided.

Copy link

@ahoienko ahoienko left a comment

Choose a reason for hiding this comment

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

Nice, but significant improvements is required

public class Application {
@RequiredArgsConstructor
public class Application implements CommandLineRunner {
private static final String RICK_AND_MORTY_API_CHARACTER_URL = "https://rickandmortyapi.com/api/character";

Choose a reason for hiding this comment

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

This parameter should be configurable (in application properties), not hardcoded

Comment on lines 2 to 3
spring.datasource.username=root
spring.datasource.password=henghfdf

Choose a reason for hiding this comment

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

Don`t push credentials to github


spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=true
spring.jpa.open-in-view=false

Choose a reason for hiding this comment

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

missing empty line

Copy link
Author

Choose a reason for hiding this comment

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

May you explain me why is it matter?

Comment on lines 1 to 5
E:\Java_projects\jv-rick-and-morty\src\main\java\mate\academy\rickandmorty\dto\external\CharacterFullResponseDto.java
E:\Java_projects\jv-rick-and-morty\src\main\java\mate\academy\rickandmorty\dto\external\CharacterResponseDto.java
E:\Java_projects\jv-rick-and-morty\src\main\java\mate\academy\rickandmorty\dto\external\CharacterMetadataDto.java
E:\Java_projects\jv-rick-and-morty\src\main\java\mate\academy\rickandmorty\dto\internal\CharacterSearchParametersDto.java
E:\Java_projects\jv-rick-and-morty\src\main\java\mate\academy\rickandmorty\controler\CharacterController.java

Choose a reason for hiding this comment

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

Are you sure that this file should be on git?

Comment on lines 3 to 8
mate\academy\rickandmorty\models\Character.class
mate\academy\rickandmorty\dto\internal\CharacterDto.class
mate\academy\rickandmorty\external\api\service\impl\ExternalCharacterServiceImpl.class
mate\academy\rickandmorty\repository\CharacterRepository.class
mate\academy\rickandmorty\dto\external\CharacterResponseDto.class
mate\academy\rickandmorty\external\api\service\ExternalCharacterService.class

Choose a reason for hiding this comment

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

Are you sure that this file should be on git?

package mate.academy.rickandmorty.external.api.service;

public interface GetClient<T> {
T getDtoFromApi(String url);

Choose a reason for hiding this comment

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

Suggested change
T getDtoFromApi(String url);
dto.... getDtoFromApi(String url);

public class Application {
@RequiredArgsConstructor
public class Application implements CommandLineRunner {
private static final String RICK_AND_MORTY_API_CHARACTER_URL = "https://rickandmortyapi.com/api/character";

Choose a reason for hiding this comment

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

Also this url can be moved to client class

}

while (true) {
fullResponseDto.getResults().forEach(externalCharacterService::saveOrUpdate);

Choose a reason for hiding this comment

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

In current implementation you will make N requests to DB to save N characters


public interface CharacterRepository extends JpaRepository<Character,Long>,
JpaSpecificationExecutor<Character> {
List<Character> findByExternalId(String externalId);

Choose a reason for hiding this comment

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

Why this returns list?

return;
}

characterMapper.updateCharacterFromResponseDto(characterResponseDto, character);

Choose a reason for hiding this comment

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

Suggested change
characterMapper.updateCharacterFromResponseDto(characterResponseDto, character);
Character updatedCharacter = characterMapper.toCharacter(characterResponseDto);
updatedCharacter.setId(existingCharacter.getId)

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