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

feat: post recommendation API #508

Merged
merged 17 commits into from
Sep 23, 2024
Merged

feat: post recommendation API #508

merged 17 commits into from
Sep 23, 2024

Conversation

siyeonSon
Copy link
Member

@siyeonSon siyeonSon added ✨feature New feature or request 🥇asap As soon as possible 😺 API Server Api Domain labels Sep 11, 2024
@siyeonSon siyeonSon self-assigned this Sep 11, 2024
Copy link
Collaborator

@seonghun-dev seonghun-dev left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다.
기존에 코드 많이 더러웠는데 깔끔하게 정리해주셨네요
감사합니다 😄 👍🏻 💯

@seonghun-dev
Copy link
Collaborator

바로 머지해주시면 오늘 테섭 배포해두겠습니다

Copy link
Member Author

@siyeonSon siyeonSon 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 +15 to +25
@GetMapping(value = "${apple.music.api.get-catalog-charts-url}", produces = MediaType.APPLICATION_JSON_VALUE)
AppleMusicSongChartResponseDto getSongCharts(
@RequestParam("types") String types,
@RequestParam("limit") int limit
);

@GetMapping(value = "${apple.music.api.get-catalog-charts-url}", produces = MediaType.APPLICATION_JSON_VALUE)
AppleMusicAlbumChartResponseDto getAlbumCharts(
@RequestParam("types") String types,
@RequestParam("limit") int limit
);
Copy link
Member Author

Choose a reason for hiding this comment

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

[추상화에 대한 고민]

두 로직은 동일한 AppleMusicAPI를 활용하지만 파라미터 값만 다르게 적용했습니다.

그런데 서로 API 응답 값이 달라서 서로 다른 DTO를 사용합니다.
같은 API를 활용한 코드라서 하나로 묶고, DTO를 최대한 재활용 하고 싶은데 적당한 방법이 떠오르지 않아서 고민이에요 🤔


import java.util.List;

public class AppleMusicSongChartResponseDto {
Copy link
Member Author

@siyeonSon siyeonSon Sep 23, 2024

Choose a reason for hiding this comment

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

[DTO 객체 생성 비용 최적화 고민]

Apple Music API 주소는 다음과 같습니다.
https://api.music.apple.com/v1/catalog/kr/charts?types=songs&limit=30

호출할 때마다 객체를 최소 30+N개 만들어야 해요. M번 호출되면 M*(30+N)개라서 메모리 효율적이지 않다고 생각합니다.
이미 만든 객체를 재활용 할 수 없을까요? DTO 객체 생성 비용 최적화에 대해서 고민이에요 🤔

Comment on lines +8 to +22
@Configuration
public class AppleMusicAuthConfig implements RequestInterceptor {

private static final String HEADER_NAME ="Authorization";
private static final String AUTH_TYPE = "Bearer";

@Value("${apple.music.api.key}")
private String value;

@Override
public void apply(RequestTemplate requestTemplate) {
requestTemplate.header(HEADER_NAME, AUTH_TYPE + " " + value);
}

}
Copy link
Member Author

Choose a reason for hiding this comment

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

Apple Music API와 통신하는 코드가 서로 통일되어 있지 않아요.

음악 검색 Apple Music API 통신은 Web Client로 작성되어 있고, 검색어 추천 Apple Music API 통신은 Feign Client로 작성했습니다.
이로 인해 설정 부분에도 차이가 존재해요. 현재 코드에 작성된 AppleMusicAuthConfig와 기존 코드의 AppleMusicConfig를 비교해보시면 좋을 것 같아요.

이전에 작성된 코드와 싱크를 맞추는 작업이 필요해요. 다만 AppleMusic API 호출 부분, 설정 부분, DTO 등 작업량이 많아질 것이라 생각해요. 별도의 브랜치에 작업하여 반영하겠습니다.

참고
Feign Client를 사용한 이유: #472 (comment)

@siyeonSon siyeonSon merged commit fd6ef8c into dev Sep 23, 2024
1 check failed
@siyeonSon siyeonSon deleted the feat/drop-recommend branch September 23, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😺 API Server Api Domain 🥇asap As soon as possible ✨feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Api] add post recommendation API
2 participants