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

♻️ separate recipe info query #445

Merged
merged 7 commits into from
Jan 6, 2025
Merged

♻️ separate recipe info query #445

merged 7 commits into from
Jan 6, 2025

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Dec 23, 2024

레시피의 정보를 찾아올 때, 조인을 남발하고 한방 쿼리로 찾아오던 것을 변경했습니다.
카테고리는 카테고리서비스에서, 재료는 재료서비스에서 찾아옵니다.
그리고 그것들을 레시피서비스에서 합칩니다!

주된 변경은 레시피서비스이니 그 부분을 시작으로 확인하시면 읽기 편할 겁니다!

- retrieve category and ingredient from respective services
- move DTOs to respective domains
Copy link
Contributor Author

Overall Project 90.21% -0.17% 🍏
Files changed 94.37% 🍏

File Coverage
RecipeDescriptionResponse.java 100% 🍏
AuthorResponse.java 100% 🍏
RecipeHomeWithMineResponse.java 100% 🍏
CategoryResponse.java 100% 🍏
CategoryService.java 100% 🍏
IngredientResponse.java 100% 🍏
Category.java 100% 🍏
CategoryRecipe.java 100% 🍏
IngredientService.java 93.06% -1.73% 🍏
RecipeService.java 87.55% -0.93% 🍏

Copy link
Contributor

@tackyu tackyu left a comment

Choose a reason for hiding this comment

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

로직을 잘 분리해주셔서 가독성이 더 좋아진 것 같아요👍
코멘트 몇 개 남겼는데 확인 부탁드립니다
고생하셨습니다!

Comment on lines 37 to 38

public List<IngredientResponse> findIngredientByRecipe(Recipe recipe) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Transactional(readOnly = true)을 안붙이신 이유가 있으신가요??

Copy link
Contributor

Choose a reason for hiding this comment

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

급해서 발견을 못했네요....
추가하겠습니다!

@@ -32,6 +35,13 @@ public void register(List<IngredientCreateRequest> requests, Recipe recipe) {
}
}

public List<IngredientResponse> findIngredientByRecipe(Recipe recipe) {
return ingredientRecipeRepository.findAllByRecipeId(recipe.getId())
Copy link
Contributor

Choose a reason for hiding this comment

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

categoryRecipeRepository.findAllByRecipe(recipe);
엔티티로 조회할지 id로 조회할지 얘기해보면 좋을 것 같아요!

Choose a reason for hiding this comment

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

크게 문제가 될것 같지는 않지만 다른 로직에서 대부분 아이디로 조회하고 있네요. 수정하는것도 좋아 보입니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

일단 카테고리를 먼저 수정했는데 카테고리엔 관련 메서드가 없어서 새로 만들었습니다!
그런데 재료에는 관련 메서드가 있어서 일단 그걸 먼저 사용했어요.
이따 회의 때 카테고리의 메서드도 통일하는게 좋을지 함께 이야기해보아요...!!

Comment on lines 12 to 13
ingredientRecipe.getRequirement())
;
Copy link
Contributor

Choose a reason for hiding this comment

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

말도안돼

Copy link
Contributor

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ
고치겠습니다................ ㅎㅎ

Comment on lines 28 to 33
public RecipeDescriptionResponse(
UserInfo userInfo,
RecipeDataResponse firstResponse,
Recipe recipe,
List<CategoryResponse> category,
List<IngredientResponse> ingredient,
boolean isLike
Copy link
Contributor

Choose a reason for hiding this comment

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

👍👍

Copy link

@HaiSeong HaiSeong left a comment

Choose a reason for hiding this comment

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

아토 코드 리뷰 완료했습니다.
기존 로직보다 훨신 깔끔하게 잘 리팩토링 하신것 같아요. 👍👍
이번 pr로 조만간 진행할 계층분리를 하기 좋은 코드가 된것 같아요.
수고하셨습니다!

@@ -32,6 +35,13 @@ public void register(List<IngredientCreateRequest> requests, Recipe recipe) {
}
}

public List<IngredientResponse> findIngredientByRecipe(Recipe recipe) {
return ingredientRecipeRepository.findAllByRecipeId(recipe.getId())

Choose a reason for hiding this comment

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

크게 문제가 될것 같지는 않지만 다른 로직에서 대부분 아이디로 조회하고 있네요. 수정하는것도 좋아 보입니다!

Comment on lines -45 to +48
userInfo.isSameUser(firstResponse.authorId()),
userInfo.isSameUser(recipe.getAuthor().getId()),

Choose a reason for hiding this comment

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

👍

Comment on lines -97 to -103
@Query("""
SELECT new net.pengcook.recipe.dto.RecipeDataResponse(
r.id,
r.title,
r.author.id,
r.author.username,
r.author.image,

Choose a reason for hiding this comment

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

👍👍

Copy link
Contributor Author

Overall Project 90.21% -0.17% 🍏
Files changed 94.37% 🍏

File Coverage
RecipeDescriptionResponse.java 100% 🍏
AuthorResponse.java 100% 🍏
RecipeHomeWithMineResponse.java 100% 🍏
CategoryResponse.java 100% 🍏
CategoryService.java 100% 🍏
IngredientResponse.java 100% 🍏
Category.java 100% 🍏
CategoryRecipe.java 100% 🍏
IngredientService.java 93.06% -1.73% 🍏
RecipeService.java 87.55% -0.93% 🍏

Copy link
Contributor Author

Overall Project 90.21% -0.17% 🍏
Files changed 94.37% 🍏

File Coverage
RecipeDescriptionResponse.java 100% 🍏
AuthorResponse.java 100% 🍏
RecipeHomeWithMineResponse.java 100% 🍏
CategoryResponse.java 100% 🍏
CategoryService.java 100% 🍏
IngredientResponse.java 100% 🍏
Category.java 100% 🍏
CategoryRecipe.java 100% 🍏
IngredientService.java 93.06% -1.73% 🍏
RecipeService.java 87.55% -0.93% 🍏

Copy link
Contributor Author

github-actions bot commented Jan 6, 2025

Overall Project 89.98% -0.89% 🍏
Files changed 85.25% 🍏

File Coverage
RecipeDescriptionResponse.java 100% 🍏
RecipeHomeResponse.java 100% 🍏
AuthorResponse.java 100% 🍏
RecipeHomeWithMineResponse.java 100% 🍏
CategoryResponse.java 100% 🍏
Comment.java 100% 🍏
CategoryService.java 100% 🍏
IngredientResponse.java 100% 🍏
Category.java 100% 🍏
CategoryRecipe.java 100% 🍏
IngredientService.java 93.06% -1.73% 🍏
RecipeService.java 86.16% -1.03% 🍏
Recipe.java 80.12% 🍏
BlockedUserFilterAspect.java 48.28% -28.45% 🍏

@hyxrxn hyxrxn merged commit 54f4e8b into be/dev Jan 6, 2025
1 check passed
@hyxrxn hyxrxn deleted the be/feat/444 branch January 6, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE Backend ♻️ refactor refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants