feat: 复习总览分页与全局汇总
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package com.guo.learningprogresstracker.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.guo.learningprogresstracker.dto.IdRange;
|
||||
import com.guo.learningprogresstracker.dto.ReviewFeedItem;
|
||||
import com.guo.learningprogresstracker.dto.ReviewSummary;
|
||||
import com.guo.learningprogresstracker.dto.ReviewTaskStats;
|
||||
import com.guo.learningprogresstracker.dto.StudyReportDetail;
|
||||
import com.guo.learningprogresstracker.dto.TaskRecallRatio;
|
||||
@@ -247,17 +250,40 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReviewTaskStats> getReviewTaskStats() {
|
||||
List<TaskEntity> tasks = tasksMapper.selectList(
|
||||
Wrappers.<TaskEntity>lambdaQuery()
|
||||
.orderByDesc(TaskEntity::getCalculatedPriority));
|
||||
public ReviewSummary summary() {
|
||||
// 口径必须与 /review/tasks 的列表一致(列表逐页相加 == 这里的汇总):
|
||||
// 报告按「报告 → 会话 → 任务」归属,碎片按内容归属(owner_task_num)统计。
|
||||
// 不能用裸表的 selectCount:那样「学习残片」会把待归类碎片也算进来,
|
||||
// 与列表逐页相加的结果对不上(待归类在总览里有独立区块展示)。
|
||||
return new ReviewSummary(
|
||||
tasksMapper.selectCount(null),
|
||||
studyReportsMapper.countOwnedReports(),
|
||||
studyReportFragmentsMapper.countOwnedFragments());
|
||||
}
|
||||
|
||||
List<ReviewTaskStats> stats = tasks.stream()
|
||||
@Override
|
||||
public Page<ReviewTaskStats> getReviewTaskStats(int pageNum, int pageSize, String markerName) {
|
||||
// 点标签即筛选:过滤下推到 SQL(EXISTS 子查询),由数据库一次算出命中任务并分页;
|
||||
// 不再「先查全部命中对象号、再拼 IN 回查」——命中量大时 IN 会膨胀。
|
||||
IPage<TaskEntity> taskPage;
|
||||
if (StringUtils.hasText(markerName)) {
|
||||
taskPage = tasksMapper.selectPageByMarker(new Page<>(pageNum, pageSize), markerName.trim());
|
||||
} else {
|
||||
taskPage = tasksMapper.selectPage(new Page<>(pageNum, pageSize),
|
||||
Wrappers.<TaskEntity>lambdaQuery()
|
||||
.orderByDesc(TaskEntity::getCalculatedPriority)
|
||||
// 优先级相同的任务之间要有稳定次序,否则翻页会重复或漏掉
|
||||
.orderByDesc(TaskEntity::getId));
|
||||
}
|
||||
List<ReviewTaskStats> stats = taskPage.getRecords().stream()
|
||||
.map(this::newTaskStats)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 聚合只算这一页的任务,不再对全部任务做 IN 聚合
|
||||
fillReviewTaskStats(stats);
|
||||
return stats;
|
||||
|
||||
Page<ReviewTaskStats> result = new Page<>(taskPage.getCurrent(), taskPage.getSize(), taskPage.getTotal());
|
||||
result.setRecords(stats);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user