HomeService fetchData 리팩토링 및 DB JOIN 기반 번역 적용

fetchData 함수에서 별도로 수행하던 번역 데이터 조회를 DB JOIN 및
COALESCE를 사용하도록 개선하여 성능을 최적화함.

- AudioContentRepository, RankingRepository 등에 locale 파라미터 추가
- DB 레벨에서 번역된 제목을 조회하도록 쿼리 수정
- HomeService에서 불필요한 getTranslatedContentList 호출 제거
This commit is contained in:
2026-02-13 10:37:06 +09:00
parent 46b0989795
commit 341f24c643
7 changed files with 102 additions and 138 deletions

View File

@@ -1222,7 +1222,7 @@ class AudioContentService(
isPointAvailableOnly = isPointAvailableOnly
)
val contentList = repository.getLatestContentByTheme(
return repository.getLatestContentByTheme(
memberId = memberId,
theme = normalizedTheme,
contentType = contentType,
@@ -1233,26 +1233,9 @@ class AudioContentService(
isAdult = isAdult,
orderByRandom = orderByRandom,
isPointAvailableOnly = isPointAvailableOnly,
excludeContentIds = excludeContentIds
excludeContentIds = excludeContentIds,
locale = langContext.lang.code
)
val contentIds = contentList.map { it.contentId }
return if (contentIds.isNotEmpty()) {
val translations = contentTranslationRepository
.findByContentIdInAndLocale(contentIds = contentIds, locale = langContext.lang.code)
.associateBy { it.contentId }
contentList.map { item ->
val translatedTitle = translations[item.contentId]?.renderedPayload?.title
if (translatedTitle.isNullOrBlank()) {
item
} else {
item.copy(title = translatedTitle)
}
}
} else {
contentList
}
}
/**