크리에이터 채널의 후원랭킹에 이미지에 imageHost를 연결하여 정상적으로 표시되도록 수정
This commit is contained in:
@@ -8,10 +8,6 @@ import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
|
|||||||
import kr.co.vividnext.sodalive.can.use.QUseCanCalculate.useCanCalculate
|
import kr.co.vividnext.sodalive.can.use.QUseCanCalculate.useCanCalculate
|
||||||
import kr.co.vividnext.sodalive.member.QMember.member
|
import kr.co.vividnext.sodalive.member.QMember.member
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
import java.time.DayOfWeek
|
|
||||||
import java.time.LocalDateTime
|
|
||||||
import java.time.LocalTime
|
|
||||||
import java.time.temporal.TemporalAdjusters
|
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class CreatorDonationRankingQueryRepository(private val queryFactory: JPAQueryFactory) {
|
class CreatorDonationRankingQueryRepository(private val queryFactory: JPAQueryFactory) {
|
||||||
@@ -19,12 +15,6 @@ class CreatorDonationRankingQueryRepository(private val queryFactory: JPAQueryFa
|
|||||||
creatorId: Long,
|
creatorId: Long,
|
||||||
limit: Long
|
limit: Long
|
||||||
): List<DonationRankingProjection> {
|
): List<DonationRankingProjection> {
|
||||||
val now = LocalDateTime.now()
|
|
||||||
val lastMonday = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
|
|
||||||
.minusWeeks(1)
|
|
||||||
.with(LocalTime.MIN)
|
|
||||||
val lastSunday = lastMonday.plusDays(6).with(LocalTime.MAX)
|
|
||||||
|
|
||||||
val donationCan = useCan.rewardCan.add(useCan.can).sum()
|
val donationCan = useCan.rewardCan.add(useCan.can).sum()
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
@@ -47,7 +37,6 @@ class CreatorDonationRankingQueryRepository(private val queryFactory: JPAQueryFa
|
|||||||
.or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE))
|
.or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE))
|
||||||
.or(useCan.canUsage.eq(CanUsage.LIVE))
|
.or(useCan.canUsage.eq(CanUsage.LIVE))
|
||||||
)
|
)
|
||||||
.and(useCan.createdAt.between(lastMonday, lastSunday))
|
|
||||||
)
|
)
|
||||||
.offset(0)
|
.offset(0)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.explorer.profile
|
|||||||
|
|
||||||
import kr.co.vividnext.sodalive.explorer.MemberDonationRankingListResponse
|
import kr.co.vividnext.sodalive.explorer.MemberDonationRankingListResponse
|
||||||
import kr.co.vividnext.sodalive.explorer.MemberDonationRankingResponse
|
import kr.co.vividnext.sodalive.explorer.MemberDonationRankingResponse
|
||||||
|
import org.springframework.beans.factory.annotation.Value
|
||||||
import org.springframework.data.redis.core.RedisTemplate
|
import org.springframework.data.redis.core.RedisTemplate
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.time.DayOfWeek
|
import java.time.DayOfWeek
|
||||||
@@ -14,14 +15,17 @@ import java.time.temporal.TemporalAdjusters
|
|||||||
@Service
|
@Service
|
||||||
class CreatorDonationRankingService(
|
class CreatorDonationRankingService(
|
||||||
private val repository: CreatorDonationRankingQueryRepository,
|
private val repository: CreatorDonationRankingQueryRepository,
|
||||||
private val redisTemplate: RedisTemplate<String, Any>
|
private val redisTemplate: RedisTemplate<String, Any>,
|
||||||
|
|
||||||
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
|
private val imageHost: String
|
||||||
) {
|
) {
|
||||||
fun getMemberDonationRanking(
|
fun getMemberDonationRanking(
|
||||||
creatorId: Long,
|
creatorId: Long,
|
||||||
limit: Long,
|
limit: Long,
|
||||||
withDonationCan: Boolean
|
withDonationCan: Boolean
|
||||||
): List<MemberDonationRankingResponse> {
|
): List<MemberDonationRankingResponse> {
|
||||||
val cacheKey = "creator_donation_ranking:$creatorId:$limit:$withDonationCan"
|
val cacheKey = "creator_donation_ranking_v2:$creatorId:$limit:$withDonationCan"
|
||||||
val cachedData = redisTemplate.opsForValue().get(cacheKey) as? MemberDonationRankingListResponse
|
val cachedData = redisTemplate.opsForValue().get(cacheKey) as? MemberDonationRankingListResponse
|
||||||
if (cachedData != null) {
|
if (cachedData != null) {
|
||||||
return cachedData.rankings
|
return cachedData.rankings
|
||||||
@@ -33,7 +37,7 @@ class CreatorDonationRankingService(
|
|||||||
MemberDonationRankingResponse(
|
MemberDonationRankingResponse(
|
||||||
it.memberId,
|
it.memberId,
|
||||||
it.nickname,
|
it.nickname,
|
||||||
it.profileImage,
|
"$imageHost/${it.profileImage}",
|
||||||
if (withDonationCan) it.donationCan else 0
|
if (withDonationCan) it.donationCan else 0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user