Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api-specs/class-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ AI가 주제 후보를 제안하면 운영자가 하나를 고르거나 직접
- `insightText`: 200자 이하다.
- `evidence`: 인사이트가 근거로 삼은 공개 글 1~5건이다.
- `highlights`: 운영자에게 추천하는 대표 의견 최대 2건이다. 작성자 정보는 넣지 않는다.
- `LIMITED`면 `insightText`가 "아직 요약할 의견이 충분하지 않아요"이고 `evidence`가 빈 배열이다. 다음 경우에 `LIMITED`가 된다.
- `LIMITED`면 `insightText`가 "판단의 이유를 살펴볼 글이 아직 충분하지 않아요"이고 `evidence`가 빈 배열이다. 다음 경우에 `LIMITED`가 된다.
- 의견 작성자가 3명 미만이다.
- 이유를 읽을 수 있는 글을 쓴 사람이 3명 미만이다. "ㅋㅋㅋ", "몰라요 그냥요", "asdfasdf", 같은 글자·숫자 반복처럼 이유가 없는 글은 세지 않는다.
- AI가 무관한 글, 의미 없는 입력, 조롱 글을 빼고 나니 작성자가 3명 미만이다.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.swyp.picke.domain.classroom.service.report.ClassReportSnapshotService;
import com.swyp.picke.domain.classroom.service.report.ClassResultStats;
import com.swyp.picke.domain.classroom.service.report.ClassResultStatsCalculator;
import com.swyp.picke.domain.classroom.service.report.ClassReportContentValidator;
import com.swyp.picke.domain.classroom.service.report.InsightPostRules;
import com.swyp.picke.domain.classroom.service.report.MemberFeedbackInput;
import com.swyp.picke.domain.classroom.service.report.ReportContent;
Expand Down Expand Up @@ -301,7 +302,9 @@ private ClassInsightResponse toInsight(Long classId, ClassReport summary, boolea
backfillHighlights(highlights, classId);
return new ClassInsightResponse(
classId, state, retryable, cutoffAt, summary.getGeneratedAt(),
ReportContent.str(insight, "insight_text"),
// 예전 문구로 저장된 LIMITED 인사이트도 현재 문구로 내려준다 (#661)
state == ClassReportViewState.LIMITED ? ClassReportContentValidator.INSIGHT_LIMITED_TEXT
: ReportContent.str(insight, "insight_text"),
ReportContent.str(insight, "coverage"),
ReportContent.asInt(insight, "excluded_count"),
evidence, highlights);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class ClassReportContentValidator {
/** 분석 불가 사유 (엣지 케이스 PRD 3.3). content.limited_reason 에 저장한다 */
public static final String LIMITED_NO_POST = "NO_POST";
public static final String LIMITED_INSUFFICIENT_EVIDENCE = "INSUFFICIENT_EVIDENCE";
/** 클래스 인사이트 의견 부족(LIMITED) 문구. 명세 8장 리포트 상태 표 기준 (#661) */
public static final String INSIGHT_LIMITED_TEXT = "판단의 이유를 살펴볼 글이 아직 충분하지 않아요";

public Map<String, Object> validateMemberFeedback(Map<String, Object> json, MemberFeedbackInput input) {
if ("INSUFFICIENT".equalsIgnoreCase(ReportContent.str(json, "analysis_status"))) {
Expand Down Expand Up @@ -276,7 +278,7 @@ static Map<String, Object> limitedClassInsight(ClassInsightInput input) {
/** 유효 공개 글 작성자 3명 미만일 때의 템플릿 (PRD §14 개인정보와 소수 의견) */
public static Map<String, Object> limitedClassInsight() {
Map<String, Object> insight = new LinkedHashMap<>();
insight.put("insight_text", "아직 요약할 의견이 충분하지 않아요");
insight.put("insight_text", INSIGHT_LIMITED_TEXT);
insight.put("evidence_ids", List.of());
insight.put("highlight_ids", List.of());
insight.put("analysis_status", "LIMITED");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.swyp.picke.domain.classroom.service.report.ReportContent;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -313,7 +314,7 @@ void afterClose_generatesReports() throws Exception {
mockMvc.perform(get(result(cls) + "/insight").header("Authorization", "Bearer " + ownerToken))
.andExpect(status().isOk())
.andExpect(jsonPath("$.data.state").value("LIMITED"))
.andExpect(jsonPath("$.data.insightText").value("아직 요약할 의견이 충분하지 않아요"))
.andExpect(jsonPath("$.data.insightText").value("판단의 이유를 살펴볼 글이 아직 충분하지 않아요"))
.andExpect(jsonPath("$.data.evidence", hasSize(0)))
.andExpect(jsonPath("$.data.highlights", hasSize(1)));

Expand Down Expand Up @@ -460,9 +461,20 @@ void insight_junkPostsOnly() throws Exception {
mockMvc.perform(get(result(cls) + "/insight").header("Authorization", "Bearer " + ownerToken))
.andExpect(status().isOk())
.andExpect(jsonPath("$.data.state").value("LIMITED"))
.andExpect(jsonPath("$.data.insightText").value("아직 요약할 의견이 충분하지 않아요"))
.andExpect(jsonPath("$.data.insightText").value("판단의 이유를 살펴볼 글이 아직 충분하지 않아요"))
.andExpect(jsonPath("$.data.highlights").isEmpty());
verify(aiClient, never()).chatJson(any(), eq(ClassReportPrompts.CLASS_INSIGHT_SYSTEM), anyString(), anyInt());

// #661 예전 문구로 저장된 LIMITED 인사이트도 현재 문구로 내려간다
ClassReport summary = summaryOf(cls.classId);
Map<String, Object> content = new java.util.LinkedHashMap<>(summary.getContent());
Map<String, Object> oldInsight = new java.util.LinkedHashMap<>(ReportContent.map(content, "insight"));
oldInsight.put("insight_text", "아직 요약할 의견이 충분하지 않아요");
content.put("insight", oldInsight);
summary.limit(content, LocalDateTime.now());
classReportRepository.saveAndFlush(summary);
mockMvc.perform(get(result(cls) + "/insight").header("Authorization", "Bearer " + ownerToken))
.andExpect(jsonPath("$.data.insightText").value("판단의 이유를 살펴볼 글이 아직 충분하지 않아요"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void insightLimitedWhenUsableAuthorsBelowThree() {
Map<String, Object> insight = validator.validateClassInsight(json, input);

assertThat(insight).containsEntry("analysis_status", "LIMITED")
.containsEntry("insight_text", "아직 요약할 의견이 충분하지 않아요");
.containsEntry("insight_text", "판단의 이유를 살펴볼 글이 아직 충분하지 않아요");
assertThat(ReportContent.stringList(insight, "evidence_ids")).isEmpty();
}

Expand All @@ -237,7 +237,7 @@ void insightInsufficient() {
Map<String, Object> insight = validator.validateClassInsight(Map.of("analysis_status", "INSUFFICIENT"), input);

assertThat(insight).containsEntry("analysis_status", "LIMITED")
.containsEntry("insight_text", "아직 요약할 의견이 충분하지 않아요");
.containsEntry("insight_text", "판단의 이유를 살펴볼 글이 아직 충분하지 않아요");
}

@Test
Expand Down
Loading