perf: Feed 只返回摘要与原文长度
This commit is contained in:
@@ -59,6 +59,8 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
private static final String SOURCE_FRAGMENT = "FRAGMENT";
|
||||
/** 待归类分组在内部的键名(不会作为任务编号出现在响应里,响应里 taskNum 为 null) */
|
||||
private static final String PENDING_OWNERSHIP_KEY = "__PENDING__";
|
||||
/** Feed 条目只返回这么长的摘要;全文由详情接口按需拉取(复习-05) */
|
||||
private static final int FEED_SUMMARY_MAX_LENGTH = 200;
|
||||
/** 时间效应封顶天数 */
|
||||
private static final int AGE_CEILING_DAYS = 90;
|
||||
/** 「稍后再看」的权重倍数(提高出现概率) */
|
||||
@@ -517,7 +519,7 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
ReviewFeedItem item = new ReviewFeedItem();
|
||||
item.setId(r.getId());
|
||||
item.setSourceType(SOURCE_REPORT);
|
||||
item.setContent(reportDisplayText(r));
|
||||
applySummary(item, reportDisplayText(r));
|
||||
item.setCreatedTime(r.getCreatedTime());
|
||||
item.setContextType(FragmentContextTypeEnum.SESSION.name());
|
||||
item.setContextNum(r.getSessionNum());
|
||||
@@ -531,7 +533,7 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
ReviewFeedItem item = new ReviewFeedItem();
|
||||
item.setId(f.getId());
|
||||
item.setSourceType(SOURCE_FRAGMENT);
|
||||
item.setContent(f.getContent());
|
||||
applySummary(item, f.getContent());
|
||||
item.setCreatedTime(f.getCreatedTime());
|
||||
item.setContextType(f.getContextType());
|
||||
item.setContextNum(f.getContextNum());
|
||||
@@ -553,6 +555,25 @@ public class ReviewServiceImpl implements ReviewService {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 把原文放进 Feed 条目:只保留摘要与总长度(复习-05)。
|
||||
* <p>摘要把换行压成空格,避免多行内容在列表里撑高卡片。</p>
|
||||
*/
|
||||
private static void applySummary(ReviewFeedItem item, String rawContent) {
|
||||
String full = rawContent == null ? "" : rawContent;
|
||||
item.setContentLength(full.length());
|
||||
if (full.length() <= FEED_SUMMARY_MAX_LENGTH) {
|
||||
item.setContent(full);
|
||||
item.setContentTruncated(false);
|
||||
return;
|
||||
}
|
||||
String summary = full.substring(0, FEED_SUMMARY_MAX_LENGTH)
|
||||
.replaceAll("\\s+", " ")
|
||||
.trim();
|
||||
item.setContent(summary);
|
||||
item.setContentTruncated(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 报告在列表/Feed 中的展示文本:结构化报告由三段组成,这里按段拼接。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user