feat(home): 인기 커뮤니티 집계 쿼리를 변경한다
This commit is contained in:
@@ -648,9 +648,10 @@ class DefaultHomeRecommendationQueryRepository(
|
||||
|
||||
override fun findPopularCommunitySnapshots(
|
||||
windowStart: LocalDateTime,
|
||||
snapshotAt: LocalDateTime,
|
||||
windowEndExclusive: LocalDateTime,
|
||||
limit: Int
|
||||
): List<RecommendationSnapshotRecord> {
|
||||
val snapshotAt = windowEndExclusive.minusSeconds(1)
|
||||
val sql = """
|
||||
with creator_debut as (
|
||||
select debut_events.creator_id as creator_id, min(debut_events.debut_at) as debut_at
|
||||
@@ -675,7 +676,7 @@ class DefaultHomeRecommendationQueryRepository(
|
||||
from creator_community_like ccl
|
||||
where ccl.is_active = true
|
||||
and ccl.created_at >= :windowStart
|
||||
and ccl.created_at <= :snapshotAt
|
||||
and ccl.created_at < :windowEndExclusive
|
||||
group by ccl.creator_community_id
|
||||
),
|
||||
comment_stats as (
|
||||
@@ -683,7 +684,7 @@ class DefaultHomeRecommendationQueryRepository(
|
||||
from creator_community_comment ccc
|
||||
where ccc.is_active = true
|
||||
and ccc.created_at >= :windowStart
|
||||
and ccc.created_at <= :snapshotAt
|
||||
and ccc.created_at < :windowEndExclusive
|
||||
group by ccc.creator_community_id
|
||||
),
|
||||
follower_stats as (
|
||||
@@ -697,9 +698,9 @@ class DefaultHomeRecommendationQueryRepository(
|
||||
(case when cc.is_comment_available = true then coalesce(cs.comment_count, 0) else 0 end) * ${RecommendationScoreSpec.COMMUNITY_COMMENT_WEIGHT} +
|
||||
coalesce(fs.follower_count, 0) * ${RecommendationScoreSpec.COMMUNITY_FOLLOWER_WEIGHT}) *
|
||||
case
|
||||
when cd.debut_at >= :boost10Start then ${RecommendationScoreSpec.NEW_BOOST_10_DAYS}
|
||||
when cd.debut_at >= :boost20Start then ${RecommendationScoreSpec.NEW_BOOST_20_DAYS}
|
||||
when cd.debut_at >= :boost30Start then ${RecommendationScoreSpec.NEW_BOOST_30_DAYS}
|
||||
when cd.debut_at >= :boost10Start then ${RecommendationScoreSpec.COMMUNITY_NEW_BOOST_10_DAYS}
|
||||
when cd.debut_at >= :boost20Start then ${RecommendationScoreSpec.COMMUNITY_NEW_BOOST_20_DAYS}
|
||||
when cd.debut_at >= :boost30Start then ${RecommendationScoreSpec.COMMUNITY_NEW_BOOST_30_DAYS}
|
||||
else ${RecommendationScoreSpec.DEFAULT_NEW_BOOST}
|
||||
end) as score,
|
||||
rand() as random_tie_breaker
|
||||
@@ -711,15 +712,27 @@ class DefaultHomeRecommendationQueryRepository(
|
||||
left join follower_stats fs on fs.creator_id = cc.member_id
|
||||
where cc.is_active = true
|
||||
and m.is_active = true
|
||||
and cc.price = 0
|
||||
and cc.price <= 0
|
||||
and cc.is_fixed = false
|
||||
and cc.created_at <= :snapshotAt
|
||||
and cc.created_at < :windowEndExclusive
|
||||
and cd.debut_at is not null
|
||||
and (
|
||||
coalesce(ls.like_count, 0) > 0
|
||||
or (cc.is_comment_available = true and coalesce(cs.comment_count, 0) > 0)
|
||||
or coalesce(fs.follower_count, 0) > 0
|
||||
)
|
||||
order by score desc, random_tie_breaker asc
|
||||
limit :limit
|
||||
""".trimIndent()
|
||||
|
||||
return executeSnapshotQuery(sql, RecommendedSectionType.POPULAR_COMMUNITY, windowStart, snapshotAt, limit)
|
||||
return executeSnapshotQuery(
|
||||
sql,
|
||||
RecommendedSectionType.POPULAR_COMMUNITY,
|
||||
windowStart,
|
||||
snapshotAt,
|
||||
limit,
|
||||
windowEndExclusive
|
||||
)
|
||||
}
|
||||
|
||||
override fun findAiCharacterRecommendationDetails(
|
||||
@@ -832,6 +845,7 @@ class DefaultHomeRecommendationQueryRepository(
|
||||
creatorCommunity.isActive.isTrue,
|
||||
member.isActive.isTrue,
|
||||
creatorCommunity.isFixed.isFalse,
|
||||
creatorCommunity.price.loe(0),
|
||||
includeAdultCommunityCondition(includeAdultCommunities),
|
||||
notBlockedCreatorCondition(memberId, member.id),
|
||||
creatorCommunity.id.`in`(communityIds)
|
||||
|
||||
@@ -52,7 +52,7 @@ interface HomeRecommendationQueryPort {
|
||||
|
||||
fun findPopularCommunitySnapshots(
|
||||
windowStart: LocalDateTime,
|
||||
snapshotAt: LocalDateTime,
|
||||
windowEndExclusive: LocalDateTime,
|
||||
limit: Int
|
||||
): List<RecommendationSnapshotRecord>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user