Repository navigation
✨ Feat: 과제 public.assignment 이중 저장 (Spring 조회 노출) - #17
Merged
Merged
Conversation
배경 - 과제가 chapter_studio.assignment에만 저장돼 public.assignment가 비어 Spring/프론트에서 과제가 보이지 않았다. 변경 - 슬라이드/퀴즈/노트처럼 persist 시 public.assignment에도 컬럼을 매핑해 이중 저장한다. - persistence_sql.py에 public_assignment_sql(), public_delete_assignment_sql() 추가. - public_persistence.py에 _insert_public_assignment() 추가하고 persist_public_content 시퀀스(슬라이드→퀴즈→노트→과제)에 연결, 삭제 섹션에 chapter_id 선삭제를 추가했다. 매핑 요약 - user_id ← course owner(context.user_id, NOT NULL) - course_id ← context.tutoring_id, chapter_id ← context.lesson_id - status = "active", total_questions ← steps 수(없으면 1) - title/description/questions는 chapter_studio 쓰기와 같은 헬퍼로 읽어 내용 일치 안전성 - Spring은 assignment를 읽기만 하므로 쓰기 충돌이 없다. - 같은 트랜잭션(persist 7/7)에서 실행하고, chapter_id 선삭제로 재생성 멱등성을 보장한다. - ON CONFLICT (id)는 PK 충돌 안전망으로 유지한다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경
과제가
chapter_studio.assignment에만 저장돼public.assignment가 비어 있어 Spring/프론트에서 과제가 조회되지 않았다. 슬라이드/퀴즈/노트는 이미 두 스키마에 이중 저장되고 있어 동일 패턴으로 과제도 맞췄다.변경
persistence_sql.py:public_assignment_sql(),public_delete_assignment_sql()추가public_persistence.py:_insert_public_assignment()추가,persist_public_content시퀀스(슬라이드→퀴즈→노트→과제)에 연결, 삭제 섹션에chapter_id선삭제 추가test_public_assignment_persistence.py신규 (컬럼 매핑, steps 빈 경우 total_questions=1 보정, title 폴백)컬럼 매핑 (chapter_studio source → public.assignment target)
new_id("asg")(Springchk_asg_id정규식과 동일 형식)context.user_id(course owner / 학습자)context.tutoring_idcontext.lesson_id"active"(Spring AssignmentStatus 초기값)assignment_meta.title(없으면 prompt 첫 줄)assignment_seed(과제 프롬프트)len(steps)(steps 비면 1)_json(steps)NOW()(SQL)source 값은
chapter_studio.assignment를 쓰는_insert_assignment와 같은 헬퍼(state_text/state_record/record_default_str_list/record_default_text/first_line)로 읽어 두 스키마 내용이 어긋나지 않게 했다.안전성
assignment를 읽기만 하므로 쓰기 충돌이 없다.persist_chapter_state7/7 단계의 같은 트랜잭션 안에서 실행한다 (새 트랜잭션을 열지 않는다).chapter_id선삭제(slide와 동일한 idempotent delete 패턴) → 재생성 멱등.ON CONFLICT (id)는 PK 충돌 안전망으로 유지.public.assignment에chapter_idUNIQUE 제약이 없어(PK는 id)ON CONFLICT (id)만으로는 재생성 시 중복이 생길 수 있으나, delete-first가 이를 막는다.검증
uv run python -m compileall app/modules/ChapterStudio_V1통과pytest -k "public or persist or assignment"→ 21 passed (신규 3 포함), 0 failed🤖 Generated with Claude Code