profile: use support history in analysis

This commit is contained in:
2026-08-05 00:51:02 +08:00
parent cef405616f
commit f09645cab0
9 changed files with 272 additions and 45 deletions
@@ -152,6 +152,23 @@ class UserProfileAnalysisServiceTest {
assertEquals(1, model.calls)
}
@Test
fun passesPersistedSupportStatsToTheNextConversationAnalysis() = withProfileStore {
val firstBatch = singleUserBatch(USER_A, 10, "support-first")
val firstModel = FakeConversationProfileModel {
result(responseFor("U1", "长期关注 Kotlin", evidenceRef = 1))
}
assertNotNull(analyze(firstBatch, firstModel))
val itemId = assertNotNull(UserProfileStore.load(USER_A)).items.single().id
val secondModel = SupportInspectingConversationProfileModel { supportStatsByUserId ->
val support = assertNotNull(supportStatsByUserId[USER_A]?.get(itemId))
assertEquals(1, support.count)
result()
}
assertNotNull(analyze(singleUserBatch(USER_A, 20, "support-second"), secondModel))
}
@Test
fun skipsModelWhenNoParticipantMeetsTheTextThreshold() = withProfileStore {
val model = FakeConversationProfileModel {
@@ -356,6 +373,27 @@ class UserProfileAnalysisServiceTest {
): ConversationProfileModelResult = behavior(profiles)
}
private class SupportInspectingConversationProfileModel(
private val behavior: suspend (
Map<Long, Map<String, ProfileItemSupportStats>>,
) -> ConversationProfileModelResult,
) : ConversationProfileModel {
override val modelName: String = "support-inspecting-profile-model"
override suspend fun analyzeConversation(
profiles: Map<Long, UserProfileSnapshot>,
batch: ConversationProfileBatch,
eligibleUserIds: Set<Long>,
): ConversationProfileModelResult = error("画像服务未调用支持统计重载")
override suspend fun analyzeConversation(
profiles: Map<Long, UserProfileSnapshot>,
batch: ConversationProfileBatch,
eligibleUserIds: Set<Long>,
supportStatsByUserId: Map<Long, Map<String, ProfileItemSupportStats>>,
): ConversationProfileModelResult = behavior(supportStatsByUserId)
}
companion object {
private const val BOT = 1L
private const val GROUP = 10L