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

[BE-REFACTOR] 바이옴 포켓몬 티어 정렬 #363

Open
wants to merge 6 commits into
base: be/develop
Choose a base branch
from

Conversation

jongmee
Copy link
Contributor

@jongmee jongmee commented Oct 13, 2024

🍄 PR 확인 사항

PR이 다음 요구 사항을 충족하는지 확인하세요. :

  • API 명세서가 업데이트 혹은 작성이 되어 있나요? -> 머지되고 작성할래요

현재 작업은 어떤 이슈를 해결한 것인지 설명해주세요.

Issue Number: #362

  • 보스 포켓몬 희귀도 높은 순으로 티어 정렬
  • 요구사항에 관계 없이 동적으로 쿼리스트링을 사용해서 정렬

기존 코드에서 변경된 점이 있다면 설명해주세요. (추가 X)

  • 있음
  • 없음

이건 제안인데요! 쿼리 스트링으로 보스 포켓몬과 야생 포켓몬들 티어 정렬 기준을 받도록 api를 수정하면 어떨까요? 사용자 활동 로그를 바탕으로 정렬 순서도 고치기로 했던 걸로 기억하는데 정렬 같은 조건문은 요구사항에 따라 바뀌는 것보다 이렇게 설계하는게 더 유연해보여서 제안합니다 :)

보스 포켓몬들에 대해 티어 높은 순으로 정렬만 요구사항이었기 때문에 쿼리스트링 default 값을 보스 포켓몬은 desc, 야생 포켓몬은 asc로 설정해보았습니다. (하위 호환성 O)

별로라면 철회하겠읍니다..

@jongmee jongmee added the BE_REFACTOR 🌿 백엔드 리팩토링 label Oct 13, 2024
@jongmee jongmee self-assigned this Oct 13, 2024
Copy link

@unifolio0 unifolio0 left a comment

Choose a reason for hiding this comment

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

역시 고퀄로 구현하셨네요! 저는 정렬 기준을 받는 거 좋다고 생각합니다!

간단한 컨벤션 리뷰라 바로 approve합니다!

구현 수고하셨어요! 👍

Comment on lines 22 to 23
}
return DESCENDING_COMPARATOR;

Choose a reason for hiding this comment

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

아래 compare과 개행 컨벤션이 안 맞는 것 같아요! 통일 부탁드려요☺️☺️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

개행 추가했습니다 !

Copy link
Contributor

@jinchiim jinchiim 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 6 to 11
public class NativePokemonComparator implements Comparator<NativePokemon> {

public static final String ASCENDING = "asc";
public static final String DESCENDING = "desc";
private static final NativePokemonComparator ASCENDING_COMPARATOR = new NativePokemonComparator(ASCENDING);
private static final NativePokemonComparator DESCENDING_COMPARATOR = new NativePokemonComparator(DESCENDING);
Copy link
Contributor

Choose a reason for hiding this comment

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

Comparator 라는 이름과 다르게 차순을 포함하는 상수도 관리하고 있는 듯 합니다!
차순은 해당 클래스의 상수로 관리하지 않고
BiomeService 에서 차순 관련 상수가 필요하다면 그곳에만 정의하는 것은 어떨까요?! 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

현재 BiomeService에서는 상수를 사용하지 않고 Comparatorcompare 메소드와 BiomeController에서만 사용하고 있습니다! 비교하는 역할을 하는 클래스인 Comparator가 비교 기준을 가지고 있는게 더 낫지 않을까요?!

Copy link
Contributor

Choose a reason for hiding this comment

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

밑에서 같이 의견 드릴게요!

@jongmee
Copy link
Contributor Author

jongmee commented Oct 16, 2024

/noti @jinchiim 폴라!!! 코멘트(이지만 질문) 달았어요 😄

@jongmee
Copy link
Contributor Author

jongmee commented Oct 16, 2024

/noti

여러분 정렬 기준 문자열을 enum으로 관리하게 되면서 컨버터 등등이 들어났는데요 😅 천천히 봐주세요.. 변경 사항이 꽤 있어서 다시 리뷰 요청합니다 🙇🏻‍♀️

제가 맡은 부분 외에 건들인게 있어서 이것만 추가 설명 적겠습니다

ConverterConfig 변경

  • ConverterConfig를 보니 org.springframework.data.mongodb.core.convert.MongoCustomConversions 이걸 빈으로 등록하고 있더라고요!
  • PokerogueApplication에서 @EnableMongoRepositories를 등록해놨습니다. (제가 초기 세팅때) 그런데 어플리케이션 클래스에 바로 설정하는건 의존성의 관점에서 별로라고 생각합니다 😅 바이옴 컨트롤러 테스트 하면서 바로 체감했습니다. web mvc 레이어만 떼다가 테스트하고 싶은데 어플리케이션에 설정이 바로 붙어있으니 모든 Data MongoDb config를 불러오더라고요 😞
  • 그래서 Data MongoDb 설정을 다룬 클래스(@Configuration)을 만들까하다가 ConverterConfig와 합쳐보았습니다. (묶어놓는게 편해서)

의견주세요!!

Copy link

@dwax1324 dwax1324 left a comment

Choose a reason for hiding this comment

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

안녕하세요 미아
테스트도 완벽해서 코멘트 드릴게 별로 없네요 ✨
고생하셨어요!!


@Configuration
public class ConverterConfig {
@EnableMongoRepositories(basePackages = {"com.pokerogue"})
public class DataMongoDbConfig {

Choose a reason for hiding this comment

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

네이밍 굿

Comment on lines +29 to +31
public ApiResponse<BiomeDetailResponse> biomeDetails(@PathVariable("id") String id,
@RequestParam(value = "boss", defaultValue = "desc") SortingCriteria bossPokemonOrder,
@RequestParam(value = "wild", defaultValue = "asc") SortingCriteria wildPokemonOrder) {

Choose a reason for hiding this comment

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

지금은 /api/v1/biome/grass?boss=asc&wild=desc 요런 api구조가 될 거 같은데
/api/v1/biome/grass?sort=boss-asc,wild-desc 이런 스타일은 어떠신지..!

}

@Override
public int compare(NativePokemon firstPokemon, NativePokemon secondPokemon) {

Choose a reason for hiding this comment

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

null 체크 해야할 것 같아요!

Copy link
Contributor

@jinchiim jinchiim left a comment

Choose a reason for hiding this comment

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

코멘트 하나 달았는데 간단해서 apporve 남깁니다!! 👍🏻


@Configuration
public class ConverterConfig {
@EnableMongoRepositories(basePackages = {"com.pokerogue"})
Copy link
Contributor

Choose a reason for hiding this comment

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

패키지가 조금 광범위한 것 같은데, repoitory가 따로 있는 것이 아니라서 쩔수 없긴 하지만
helper 까지만이라도 줄여볼까요?? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE_REFACTOR 🌿 백엔드 리팩토링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants