feat(recommend): 추천 점수 산식 상수를 분리한다

This commit is contained in:
2026-05-31 00:56:59 +09:00
parent 602063863a
commit a7e17fede2
3 changed files with 70 additions and 12 deletions

View File

@@ -18,16 +18,22 @@ class RecommendationScorePolicy {
communicationScore: Long,
newBoost: Double
): Double {
return ((followIncrease * 0.35) + (contentActivityScore * 0.3) + (communicationScore * 0.2)) * newBoost
return (
(followIncrease * RecommendationScoreSpec.DEBUT_FOLLOW_INCREASE_WEIGHT) +
(contentActivityScore * RecommendationScoreSpec.DEBUT_CONTENT_ACTIVITY_WEIGHT) +
(communicationScore * RecommendationScoreSpec.DEBUT_COMMUNICATION_WEIGHT)
) * newBoost
}
fun calculateAiChatScore(
recentChatCount: Long,
recentActiveUserCount: Long,
followIncrease: Long,
newBoost: Double
): Double {
return ((0.45 * recentChatCount) + (0.35 * recentActiveUserCount) + (0.20 * followIncrease)) * newBoost
return (
(RecommendationScoreSpec.AI_RECENT_CHAT_WEIGHT * recentChatCount) +
(RecommendationScoreSpec.AI_RECENT_ACTIVE_USER_WEIGHT * recentActiveUserCount)
) * newBoost
}
fun calculateCheerScore(
@@ -36,7 +42,11 @@ class RecommendationScorePolicy {
donationCount: Long,
newBoost: Double
): Double {
return ((0.6 * donationAmount) + (0.3 * fanTalkCount) + (0.1 * donationCount)) * newBoost
return (
(RecommendationScoreSpec.CHEER_DONATION_AMOUNT_WEIGHT * donationAmount) +
(RecommendationScoreSpec.CHEER_FAN_TALK_WEIGHT * fanTalkCount) +
(RecommendationScoreSpec.CHEER_DONATION_COUNT_WEIGHT * donationCount)
) * newBoost
}
fun calculateCommunityScore(
@@ -45,7 +55,11 @@ class RecommendationScorePolicy {
followerCount: Long,
newBoost: Double
): Double {
return ((0.5 * likeCount) + (0.5 * commentCount) + (0.1 * followerCount)) * newBoost
return (
(RecommendationScoreSpec.COMMUNITY_LIKE_WEIGHT * likeCount) +
(RecommendationScoreSpec.COMMUNITY_COMMENT_WEIGHT * commentCount) +
(RecommendationScoreSpec.COMMUNITY_FOLLOWER_WEIGHT * followerCount)
) * newBoost
}
fun calculateFirstAudioRecencyScore(releaseDate: LocalDateTime, now: LocalDateTime): Int {
@@ -63,10 +77,10 @@ class RecommendationScorePolicy {
private fun calculateNewBoost(baseAt: LocalDateTime, now: LocalDateTime): Double {
val days = ChronoUnit.DAYS.between(baseAt.toLocalDate(), now.toLocalDate())
return when {
days <= 10 -> 1.5
days <= 20 -> 1.3
days <= 30 -> 1.2
else -> 1.0
days <= RecommendationScoreSpec.NEW_BOOST_10_DAY_LIMIT -> RecommendationScoreSpec.NEW_BOOST_10_DAYS
days <= RecommendationScoreSpec.NEW_BOOST_20_DAY_LIMIT -> RecommendationScoreSpec.NEW_BOOST_20_DAYS
days <= RecommendationScoreSpec.NEW_BOOST_30_DAY_LIMIT -> RecommendationScoreSpec.NEW_BOOST_30_DAYS
else -> RecommendationScoreSpec.DEFAULT_NEW_BOOST
}
}
}

View File

@@ -0,0 +1,27 @@
package kr.co.vividnext.sodalive.v2.recommend.domain
object RecommendationScoreSpec {
const val NEW_BOOST_10_DAY_LIMIT = 10L
const val NEW_BOOST_20_DAY_LIMIT = 20L
const val NEW_BOOST_30_DAY_LIMIT = 30L
const val DEBUT_FOLLOW_INCREASE_WEIGHT = 0.35
const val DEBUT_CONTENT_ACTIVITY_WEIGHT = 0.3
const val DEBUT_COMMUNICATION_WEIGHT = 0.2
const val AI_RECENT_CHAT_WEIGHT = 0.45
const val AI_RECENT_ACTIVE_USER_WEIGHT = 0.35
const val CHEER_DONATION_AMOUNT_WEIGHT = 0.6
const val CHEER_FAN_TALK_WEIGHT = 0.3
const val CHEER_DONATION_COUNT_WEIGHT = 0.1
const val COMMUNITY_LIKE_WEIGHT = 0.5
const val COMMUNITY_COMMENT_WEIGHT = 0.5
const val COMMUNITY_FOLLOWER_WEIGHT = 0.1
const val NEW_BOOST_10_DAYS = 1.5
const val NEW_BOOST_20_DAYS = 1.3
const val NEW_BOOST_30_DAYS = 1.2
const val DEFAULT_NEW_BOOST = 1.0
}