번역 제목 조회 방식 수정
This commit is contained in:
@@ -6,6 +6,7 @@ import kr.co.vividnext.sodalive.content.ContentType
|
||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||
import kr.co.vividnext.sodalive.content.comment.QAudioContentComment.audioContentComment
|
||||
import kr.co.vividnext.sodalive.content.like.QAudioContentLike.audioContentLike
|
||||
import kr.co.vividnext.sodalive.content.translation.ContentTranslationPayload
|
||||
import kr.co.vividnext.sodalive.content.translation.QContentTranslation.contentTranslation
|
||||
import kr.co.vividnext.sodalive.member.MemberRole
|
||||
import kr.co.vividnext.sodalive.member.QMember.member
|
||||
@@ -101,30 +102,23 @@ class RecommendChannelQueryRepository(
|
||||
where = where.and(audioContent.isAdult.isFalse)
|
||||
}
|
||||
|
||||
val titleExpression = if (locale != null) {
|
||||
val translatedTitle = Expressions.stringTemplate(
|
||||
"JSON_EXTRACT({0}, '$.title')",
|
||||
contentTranslation.renderedPayload
|
||||
)
|
||||
val coalesceTitle = Expressions.stringTemplate(
|
||||
"COALESCE(NULLIF({0}, ''), {1})",
|
||||
translatedTitle,
|
||||
audioContent.title
|
||||
)
|
||||
coalesceTitle
|
||||
val coverImageUrl = audioContent.coverImage.prepend("/").prepend(imageHost)
|
||||
val payloadExpression = if (locale != null) {
|
||||
contentTranslation.renderedPayload
|
||||
} else {
|
||||
audioContent.title
|
||||
Expressions.nullExpression(ContentTranslationPayload::class.java)
|
||||
}
|
||||
val likeCountExpression = audioContentLike.id.countDistinct()
|
||||
val commentCountExpression = audioContentComment.id.countDistinct()
|
||||
|
||||
var select = queryFactory
|
||||
.select(
|
||||
QRecommendChannelContentItem(
|
||||
audioContent.id,
|
||||
titleExpression,
|
||||
audioContent.coverImage.prepend("/").prepend(imageHost),
|
||||
audioContentLike.id.countDistinct(),
|
||||
audioContentComment.id.countDistinct()
|
||||
)
|
||||
audioContent.id,
|
||||
audioContent.title,
|
||||
payloadExpression,
|
||||
coverImageUrl,
|
||||
likeCountExpression,
|
||||
commentCountExpression
|
||||
)
|
||||
.from(audioContent)
|
||||
.leftJoin(audioContentLike)
|
||||
@@ -151,11 +145,29 @@ class RecommendChannelQueryRepository(
|
||||
select = select.leftJoin(blockMember).on(blockMemberCondition)
|
||||
}
|
||||
|
||||
return select
|
||||
val results = select
|
||||
.where(where)
|
||||
.groupBy(audioContent.id)
|
||||
.orderBy(audioContentLike.id.countDistinct().desc())
|
||||
.orderBy(likeCountExpression.desc())
|
||||
.limit(3)
|
||||
.fetch()
|
||||
|
||||
return results.map { row ->
|
||||
val contentId = row.get(audioContent.id)!!
|
||||
val originTitle = row.get(audioContent.title)!!
|
||||
val payload = row.get(payloadExpression)
|
||||
val translatedTitle = payload?.title
|
||||
val thumbnailImageUrl = row.get(coverImageUrl)!!
|
||||
val likeCount = row.get(likeCountExpression) ?: 0L
|
||||
val commentCount = row.get(commentCountExpression) ?: 0L
|
||||
|
||||
RecommendChannelContentItem(
|
||||
contentId = contentId,
|
||||
title = if (translatedTitle.isNullOrBlank()) originTitle else translatedTitle,
|
||||
thumbnailImageUrl = thumbnailImageUrl,
|
||||
likeCount = likeCount,
|
||||
commentCount = commentCount
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import kr.co.vividnext.sodalive.content.main.QContentCreatorResponse
|
||||
import kr.co.vividnext.sodalive.content.main.QGetAudioContentRankingItem
|
||||
import kr.co.vividnext.sodalive.content.order.QOrder.order
|
||||
import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme
|
||||
import kr.co.vividnext.sodalive.content.translation.ContentTranslationPayload
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.QSeries.series
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.QSeriesContent.seriesContent
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.Series
|
||||
@@ -112,35 +113,27 @@ class RankingRepository(
|
||||
where = where.and(audioContentTheme.theme.eq(theme))
|
||||
}
|
||||
|
||||
val titleExpression = if (locale != null) {
|
||||
val translatedTitle = Expressions.stringTemplate(
|
||||
"JSON_EXTRACT({0}, '$.title')",
|
||||
contentTranslation.renderedPayload
|
||||
)
|
||||
val coalesceTitle = Expressions.stringTemplate(
|
||||
"COALESCE(NULLIF({0}, ''), {1})",
|
||||
translatedTitle,
|
||||
audioContent.title
|
||||
)
|
||||
coalesceTitle
|
||||
val coverImageUrl = audioContent.coverImage.prepend("/").prepend(imageHost)
|
||||
val creatorProfileImageUrl = member.profileImage.prepend("/").prepend(imageHost)
|
||||
val payloadExpression = if (locale != null) {
|
||||
contentTranslation.renderedPayload
|
||||
} else {
|
||||
audioContent.title
|
||||
Expressions.nullExpression(ContentTranslationPayload::class.java)
|
||||
}
|
||||
|
||||
var select = queryFactory
|
||||
.select(
|
||||
QGetAudioContentRankingItem(
|
||||
audioContent.id,
|
||||
titleExpression,
|
||||
audioContent.coverImage.prepend("/").prepend(imageHost),
|
||||
audioContentTheme.theme,
|
||||
audioContent.price,
|
||||
audioContent.duration,
|
||||
member.id,
|
||||
member.nickname,
|
||||
audioContent.isPointAvailable,
|
||||
member.profileImage.prepend("/").prepend(imageHost)
|
||||
)
|
||||
audioContent.id,
|
||||
audioContent.title,
|
||||
payloadExpression,
|
||||
coverImageUrl,
|
||||
audioContentTheme.theme,
|
||||
audioContent.price,
|
||||
audioContent.duration,
|
||||
member.id,
|
||||
member.nickname,
|
||||
audioContent.isPointAvailable,
|
||||
creatorProfileImageUrl
|
||||
)
|
||||
|
||||
select = when (sortType) {
|
||||
@@ -258,10 +251,38 @@ class RankingRepository(
|
||||
}
|
||||
}
|
||||
|
||||
return select
|
||||
val results = select
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.fetch()
|
||||
|
||||
return results.map { row ->
|
||||
val contentId = row.get(audioContent.id)!!
|
||||
val originTitle = row.get(audioContent.title)!!
|
||||
val payload = row.get(payloadExpression)
|
||||
val translatedTitle = payload?.title
|
||||
val imageUrl = row.get(coverImageUrl)!!
|
||||
val themeStr = row.get(audioContentTheme.theme) ?: ""
|
||||
val price = row.get(audioContent.price) ?: 0
|
||||
val duration = row.get(audioContent.duration) ?: ""
|
||||
val creatorId = row.get(member.id)!!
|
||||
val creatorNickname = row.get(member.nickname)!!
|
||||
val isPointAvailable = row.get(audioContent.isPointAvailable) ?: false
|
||||
val creatorProfileImageUrlValue = row.get(creatorProfileImageUrl)!!
|
||||
|
||||
GetAudioContentRankingItem(
|
||||
contentId = contentId,
|
||||
title = if (translatedTitle.isNullOrBlank()) originTitle else translatedTitle,
|
||||
coverImageUrl = imageUrl,
|
||||
themeStr = themeStr,
|
||||
price = price,
|
||||
duration = duration,
|
||||
creatorId = creatorId,
|
||||
creatorNickname = creatorNickname,
|
||||
isPointAvailable = isPointAvailable,
|
||||
creatorProfileImageUrl = creatorProfileImageUrlValue
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun getSeriesRanking(
|
||||
|
||||
Reference in New Issue
Block a user