-
Notifications
You must be signed in to change notification settings - Fork 0
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
✨ [Feature/vote] implement getting candidates API #78
Conversation
⚙️ [chore/develop] update .gitignore file
…ringBootTest for testing redis
@@ -19,6 +18,7 @@ | |||
@RequiredArgsConstructor | |||
public class RoutePersistenceAdapter implements SaveRoutePort, RetrieveRoutePort { | |||
|
|||
public static final List<String> ROUTE_ONE_LIST = List.of("경부선", "경인선", "경원선", "장항선"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1호선 네이밍 통일 관련 작업을 코드 레벨에 반영했습니다!
@@ -153,4 +164,17 @@ private double calculateDistance(Point p1, Station station) { | |||
// 유클리드 거리 공식 적용 | |||
return Math.sqrt(Math.pow(lat2 - lat1, 2) + Math.pow(lon2 - lon1, 2)); | |||
} | |||
|
|||
@Override | |||
@Cacheable(value = "recommendStations", cacheManager = "stationCacheManager", key = "#roomId") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
캐시에서 지하철 추천 목록을 조회해옵니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이부분 저랑 좀 맞춰보죠!
Station station, | ||
List<Route> routes, | ||
TmapPublicTransportationParsedResponse transportationParsedResponse, | ||
List<CommentResponse> comments //comment 도메인 구현 시 List<Comment>로 교체 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
응답 정의를 위해 우선 CommentResponse를 생성하였습니다.
추후에 댓글 추가/조회 API가 구현된다면 해당 usecase를 사용하여 관련 응답을 반영 예정입니다.
|
||
public record RouteResponse( | ||
String name | ||
//TODO: String color |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분이 고민됩니다.
호선 색깔 정보를 함께 반환해야하는데, 색깔 정보를 따로 DB에서 저장하지 않고 있다보니 Tmap API를 통해서만 색깔 정보를 조회할 수 있어요.
어떻게 처리하면 좋을지 두분의 의견이 필요합니다..ㅜㅜ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Git에서 리뷰할 때는 코드 스니펫만 보이고 전체 로직을 보기가 좀 힘들어서 그런데 공공데이터 API를 호출해서 저장한 DB에는 호선에 대한 색상 정보가 없고 Tmap API를 호출해서 호선 색상 정보를 받아와야해서 고민이신걸까요?
음,, 몇가지 방법이 떠오르는건
- Tmap API를 호출하는 시점에서 호선 색깔 정보를 같이 캐싱하는 방법. 이렇게 하면 DB에도 별도 컬럼 추가할 필요도 없고 API 호출을 최소화할 수 있고 구현도 간단함. Spring 캐시 또는 Redis Cache 어떤 것이든 괜찮을 것 같아요.
- DB에 컬럼을 추가하고 받아온 색상 정보를 DB에 업데이트하는 방법
- 지하철 색상 정보가 그렇게 변경되는 정보가 아니기 때문에 정적 파일 등으로 추가하고 반환하는 방법
등이 있을 것 같아요! 전체 로직은 봐야하겠지만 전 캐싱이 제일 좋을 것 같습니다 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
호선색깔 필요없다고 하셨습니다 (디자이너 피셜)
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class VoteCommandRedisAdapter implements SaveVotePort { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
투표 결과를 저장하는 Adapter입니다! 해당 어댑터는 추후 투표 생성 API를 개발하면서 변경될 가능성이 높기 때문에 이번 pr에선 리뷰하지 않는 것을 권장합니다 ㅎㅎ
@@ -39,4 +49,37 @@ void doesNotSaveStationsIfAlreadyExists() { | |||
// then | |||
assertThat(stationRepository.findAll()).hasSize(1); | |||
} | |||
|
|||
//TODO: 적절한 테스트 방법이 떠오르지 않아요. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그렇습니다...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 남겨놓았습니다 👍
PR 보니까 작업하신 부분이 많네요! 투표 API 구현하느라 고생하셨습니다. 😄
|
||
public record RouteResponse( | ||
String name | ||
//TODO: String color |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Git에서 리뷰할 때는 코드 스니펫만 보이고 전체 로직을 보기가 좀 힘들어서 그런데 공공데이터 API를 호출해서 저장한 DB에는 호선에 대한 색상 정보가 없고 Tmap API를 호출해서 호선 색상 정보를 받아와야해서 고민이신걸까요?
음,, 몇가지 방법이 떠오르는건
- Tmap API를 호출하는 시점에서 호선 색깔 정보를 같이 캐싱하는 방법. 이렇게 하면 DB에도 별도 컬럼 추가할 필요도 없고 API 호출을 최소화할 수 있고 구현도 간단함. Spring 캐시 또는 Redis Cache 어떤 것이든 괜찮을 것 같아요.
- DB에 컬럼을 추가하고 받아온 색상 정보를 DB에 업데이트하는 방법
- 지하철 색상 정보가 그렇게 변경되는 정보가 아니기 때문에 정적 파일 등으로 추가하고 반환하는 방법
등이 있을 것 같아요! 전체 로직은 봐야하겠지만 전 캐싱이 제일 좋을 것 같습니다 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 Candidate는 Redis에서 보관중인 내용을 투표 시작 시점에 가져가서 저장하는 용도인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞아요! 투표 시작 시점을 명확하게 알 수 없기 때문에, 후보지 조회 서비스에서 존재하지 않는다면 캐시에서 값을 가져와서 저장하고, 캐시를 지우도록 구현했어요!
@@ -153,4 +164,17 @@ private double calculateDistance(Point p1, Station station) { | |||
// 유클리드 거리 공식 적용 | |||
return Math.sqrt(Math.pow(lat2 - lat1, 2) + Math.pow(lon2 - lon1, 2)); | |||
} | |||
|
|||
@Override | |||
@Cacheable(value = "recommendStations", cacheManager = "stationCacheManager", key = "#roomId") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이부분 저랑 좀 맞춰보죠!
|
||
public record RouteResponse( | ||
String name | ||
//TODO: String color |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
호선색깔 필요없다고 하셨습니다 (디자이너 피셜)
LGTM~~! |
@@ -193,22 +187,10 @@ private double calculateDistance(Point p1, Station station) { | |||
return Math.sqrt(Math.pow(lat2 - lat1, 2) + Math.pow(lon2 - lon1, 2)); | |||
} | |||
|
|||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다. 삭제로직은 급한거 아니니까 런칭 이후로 보시죠!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ㅎㅎㅎ
확인 했습니다! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 👍
#️⃣ 연관된 이슈
📝 작업 내용
📸 스크린샷 (선택)
💬 리뷰 요구사항(선택)