refactor: 首页feed仅返回残片

This commit is contained in:
2026-08-03 23:08:14 +08:00
parent c8d0584f11
commit 5b6f7d6a2a
5 changed files with 23 additions and 32 deletions
@@ -62,13 +62,13 @@ class ReviewServiceImplTest {
void getReviewFeed_smartMode_prefersLowRecallRatioContent() {
LocalDateTime now = LocalDateTime.now();
StudyReportsEntity oldLowMastery = new StudyReportsEntity();
StudyReportFragmentsEntity oldLowMastery = new StudyReportFragmentsEntity();
oldLowMastery.setId(1);
oldLowMastery.setSessionNum("S_LOW");
oldLowMastery.setContent("很久没复习且掌握度低");
oldLowMastery.setCreatedTime(now.minusDays(60));
StudyReportsEntity freshHighMastery = new StudyReportsEntity();
StudyReportFragmentsEntity freshHighMastery = new StudyReportFragmentsEntity();
freshHighMastery.setId(2);
freshHighMastery.setSessionNum("S_HIGH");
freshHighMastery.setContent("刚学完且掌握度高");
@@ -93,8 +93,7 @@ class ReviewServiceImplTest {
highRatioRecord.setRecallRatio(1.0);
highRatioRecord.setCreatedTime(now);
when(studyReportsMapper.selectList(any())).thenReturn(List.of(oldLowMastery, freshHighMastery));
when(studyReportFragmentsMapper.selectList(any())).thenReturn(List.of());
when(studyReportFragmentsMapper.selectList(any())).thenReturn(List.of(oldLowMastery, freshHighMastery));
when(studySessionsMapper.selectList(any())).thenReturn(List.of(sessionLow, sessionHigh));
when(tasksMapper.selectList(any())).thenReturn(List.of(taskLow, taskHigh));
when(reviewRecallRecordMapper.selectList(any())).thenReturn(List.of(highRatioRecord));
@@ -116,15 +115,9 @@ class ReviewServiceImplTest {
}
@Test
void getReviewFeed_shouldApplyFinalLimitAfterMerge() {
StudyReportsEntity report = new StudyReportsEntity();
report.setId(1);
report.setSessionNum("S1");
report.setContent("report");
report.setCreatedTime(LocalDateTime.now());
void getReviewFeed_shouldReturnFragmentsOnly() {
StudyReportFragmentsEntity fragment = new StudyReportFragmentsEntity();
fragment.setId(2);
fragment.setId(1);
fragment.setSessionNum("S1");
fragment.setContent("fragment");
fragment.setCreatedTime(LocalDateTime.now().minusMinutes(1));
@@ -137,7 +130,6 @@ class ReviewServiceImplTest {
task.setTaskNum("T1");
task.setTaskName("Task");
when(studyReportsMapper.selectList(any())).thenReturn(List.of(report));
when(studyReportFragmentsMapper.selectList(any())).thenReturn(List.of(fragment));
when(studySessionsMapper.selectList(any())).thenReturn(List.of(session));
when(tasksMapper.selectList(any())).thenReturn(List.of(task));
@@ -145,7 +137,7 @@ class ReviewServiceImplTest {
List<ReviewFeedItem> items = reviewService.getReviewFeed(1, "recent");
assertEquals(1, items.size());
assertEquals("REPORT", items.get(0).getSourceType());
assertEquals("FRAGMENT", items.get(0).getSourceType());
assertEquals("Task", items.get(0).getTaskName());
}