perf: 覆盖率查询改为按任务分组取最新
This commit is contained in:
@@ -5,6 +5,7 @@ import com.guo.learningprogresstracker.dto.IdRange;
|
||||
import com.guo.learningprogresstracker.dto.ReviewFeedItem;
|
||||
import com.guo.learningprogresstracker.dto.ReviewTaskStats;
|
||||
import com.guo.learningprogresstracker.dto.StudyReportDetail;
|
||||
import com.guo.learningprogresstracker.dto.TaskRecallRatio;
|
||||
import com.guo.learningprogresstracker.dto.TaskContentCount;
|
||||
import com.guo.learningprogresstracker.dto.TaskReviewDuration;
|
||||
import com.guo.learningprogresstracker.dto.TaskSessionStats;
|
||||
@@ -172,14 +173,10 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
if (taskNums.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<ReviewRecallRecordEntity> records = reviewRecallRecordMapper.selectList(
|
||||
Wrappers.<ReviewRecallRecordEntity>lambdaQuery()
|
||||
.in(ReviewRecallRecordEntity::getTaskNum, taskNums)
|
||||
.orderByDesc(ReviewRecallRecordEntity::getCreatedTime));
|
||||
// 复习-04:在 SQL 侧按任务分组取最新一条,只带回 任务编号 + 覆盖率
|
||||
Map<String, Double> result = new HashMap<>();
|
||||
for (ReviewRecallRecordEntity record : records) {
|
||||
result.putIfAbsent(record.getTaskNum(),
|
||||
record.getRecallRatio() == null ? 0D : record.getRecallRatio());
|
||||
for (TaskRecallRatio row : reviewRecallRecordMapper.selectLatestRatioByTask(taskNums)) {
|
||||
result.put(row.getTaskNum(), row.getRecallRatio() == null ? 0D : row.getRecallRatio());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user