탐색 - 인기 급상승 제거, 인기 크리에이터 섹션 추가 #42
|
@ -0,0 +1,22 @@
|
|||
package kr.co.vividnext.sodalive.explorer
|
||||
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.FetchType
|
||||
import javax.persistence.GeneratedValue
|
||||
import javax.persistence.GenerationType
|
||||
import javax.persistence.Id
|
||||
import javax.persistence.JoinColumn
|
||||
import javax.persistence.OneToOne
|
||||
|
||||
@Entity
|
||||
data class CreatorRanking(
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
var id: Long? = null,
|
||||
val ranking: Int
|
||||
) {
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "creator_id", nullable = false)
|
||||
var member: Member? = null
|
||||
}
|
|
@ -10,6 +10,7 @@ import kr.co.vividnext.sodalive.can.use.QUseCanCalculate.useCanCalculate
|
|||
import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||
import kr.co.vividnext.sodalive.explorer.QCreatorRanking.creatorRanking
|
||||
import kr.co.vividnext.sodalive.explorer.follower.GetFollowerListDto
|
||||
import kr.co.vividnext.sodalive.explorer.follower.QGetFollowerListDto
|
||||
import kr.co.vividnext.sodalive.explorer.profile.ChannelNotice
|
||||
|
@ -158,21 +159,6 @@ class ExplorerQueryRepository(
|
|||
}
|
||||
}
|
||||
|
||||
fun getSubscriberGrowthRankingCreators(limit: Long): List<Member> {
|
||||
return queryFactory
|
||||
.selectFrom(member)
|
||||
.join(member.follower, creatorFollowing)
|
||||
.where(
|
||||
member.role.eq(MemberRole.CREATOR)
|
||||
.and(creatorFollowing.createdAt.goe(LocalDateTime.now().minusMonths(1)))
|
||||
.and(creatorFollowing.isActive.isTrue)
|
||||
)
|
||||
.groupBy(member.id)
|
||||
.orderBy(member.follower.size().desc())
|
||||
.limit(limit)
|
||||
.fetch()
|
||||
}
|
||||
|
||||
fun getNewCreators(): List<Member> {
|
||||
return queryFactory
|
||||
.selectFrom(member)
|
||||
|
@ -636,4 +622,13 @@ class ExplorerQueryRepository(
|
|||
.where(member.id.eq(creatorId))
|
||||
.fetchFirst()
|
||||
}
|
||||
|
||||
fun getCreatorRankings(): List<Member> {
|
||||
return queryFactory
|
||||
.select(member)
|
||||
.from(creatorRanking)
|
||||
.innerJoin(creatorRanking.member, member)
|
||||
.orderBy(creatorRanking.ranking.asc())
|
||||
.fetch()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ import org.springframework.stereotype.Service
|
|||
import org.springframework.transaction.annotation.Transactional
|
||||
import java.time.DayOfWeek
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.temporal.TemporalAdjusters
|
||||
|
||||
@Service
|
||||
|
@ -42,9 +44,9 @@ class ExplorerService(
|
|||
fun getExplorer(member: Member, growthRankingCreatorsLimit: Long = 20): GetExplorerResponse {
|
||||
val sections = mutableListOf<GetExplorerSectionResponse>()
|
||||
|
||||
// 인기 급상승중 (subscriberGrowthRankingCreators)
|
||||
val growthRankingCreators = queryRepository
|
||||
.getSubscriberGrowthRankingCreators(limit = growthRankingCreatorsLimit)
|
||||
// 인기 크리에이터
|
||||
val creatorRankings = queryRepository
|
||||
.getCreatorRankings()
|
||||
.asSequence()
|
||||
.filter { !memberService.isBlocked(blockedMemberId = member.id!!, memberId = it.id!!) }
|
||||
.map {
|
||||
|
@ -65,13 +67,25 @@ class ExplorerService(
|
|||
}
|
||||
.toList()
|
||||
|
||||
val growthRankingSection = GetExplorerSectionResponse(
|
||||
title = "인기 급상승중",
|
||||
val currentDateTime = LocalDateTime.now()
|
||||
val lastMonday = currentDateTime
|
||||
.minusWeeks(1)
|
||||
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
|
||||
val lastSunday = lastMonday
|
||||
.plusDays(6)
|
||||
|
||||
val formatter = DateTimeFormatter.ofPattern("MM월 dd일")
|
||||
val formattedLastMonday = lastMonday.format(formatter)
|
||||
val formattedLastSunday = lastSunday.format(formatter)
|
||||
|
||||
val creatorRankingSection = GetExplorerSectionResponse(
|
||||
title = "인기 크리에이터",
|
||||
coloredTitle = "인기",
|
||||
color = "FF5C49",
|
||||
creators = growthRankingCreators
|
||||
desc = "$formattedLastMonday~$formattedLastSunday\n※ 인기 크리에이터의 순위는 매주 업데이트 됩니다.",
|
||||
creators = creatorRankings
|
||||
)
|
||||
sections.add(growthRankingSection)
|
||||
sections.add(creatorRankingSection)
|
||||
|
||||
// 새로 시작 (newCreators)
|
||||
val newCreators = queryRepository
|
||||
|
|
|
@ -6,6 +6,7 @@ data class GetExplorerSectionResponse(
|
|||
val title: String,
|
||||
val coloredTitle: String?,
|
||||
val color: String?,
|
||||
val desc: String? = null,
|
||||
val creators: List<GetExplorerSectionCreatorResponse>
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue