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

HW41-solution #56

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

Conversation

OleksiiKolinko
Copy link

No description provided.

Comment on lines 10 to 21
private static RickAndMortyClient rickAndMortyClient;
private static RickAndMortyService rickAndMortyService;

public Application(RickAndMortyClient client, RickAndMortyService rickAndMortyService) {
Application.rickAndMortyClient = client;
Application.rickAndMortyService = rickAndMortyService;
}

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
rickAndMortyService.saveAll(rickAndMortyClient.getAllCharacter());
}

Choose a reason for hiding this comment

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

use CommandLineRunner or ApplicationRunner instead of running this here

Suggested change
private static RickAndMortyClient rickAndMortyClient;
private static RickAndMortyService rickAndMortyService;
public Application(RickAndMortyClient client, RickAndMortyService rickAndMortyService) {
Application.rickAndMortyClient = client;
Application.rickAndMortyService = rickAndMortyService;
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
rickAndMortyService.saveAll(rickAndMortyClient.getAllCharacter());
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

public List<CharacterRateDto> getAllCharacter() {
HttpClient httpClient = HttpClient.newHttpClient();
int i = 1;
List<CharacterRateDto> allCharacter = new ArrayList<>();

Choose a reason for hiding this comment

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

better naming

Suggested change
List<CharacterRateDto> allCharacter = new ArrayList<>();
List<CharacterRateDto> fetchedCharacters = new ArrayList<>();


public List<CharacterRateDto> getAllCharacter() {
HttpClient httpClient = HttpClient.newHttpClient();
int i = 1;

Choose a reason for hiding this comment

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

better naming

Suggested change
int i = 1;
int page = 1;

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