Skip to content

fix(review): persist last_review + correct resolver enrollment key#37

Open
jongjunn wants to merge 1 commit into
mainfrom
fix/review-card-last-review-and-resolver-key
Open

fix(review): persist last_review + correct resolver enrollment key#37
jongjunn wants to merge 1 commit into
mainfrom
fix/review-card-last-review-and-resolver-key

Conversation

@jongjunn

Copy link
Copy Markdown
Contributor

무엇을 / 왜

야간 FSRS 복습 배치(review_update)가 08:10 배포로 살아난 뒤 확인 중 발견한 프로덕션 버그 2건 (둘 다 infrastructure/repositories.py).

1. save_cardlast_review를 저장 안 함 → 멱등성 붕괴 (stability 왜곡)

review_card.last_review가 항상 NULL로 남아, find_review_targets의 멱등성 조건
rc.last_review IS NULL OR qs.submitted_at > rc.last_review항상 참 → 야간 배치가 매 실행마다 전 카드를 재리뷰. 코드 주석이 경고한 "같은 카드를 매일 다시 굽는" 상황(당일 재리뷰 → FSRS stability 왜곡)이 실제로 발생.

실측: 같은 날 수동 재실행 시 targets=453 updated=453 skipped=0 (아침에 갱신한 카드가 하나도 스킵 안 됨).

수정: INSERT 컬럼·ON DUPLICATE KEY UPDATE에 last_review 추가.

2. MySQLEnrollmentQuizResolver.get_member_id 잘못된 키 컬럼

SELECT ... FROM enrollment WHERE id = %senrollment PK는 enrollment_id이고 id 컬럼은 없음(V1__baseline.sql). Unknown column 'id'유사문제 추천 경로 전체가 실패. WHERE enrollment_id = %s로 수정.

영향

후속(이 PR 범위 밖, 별도 확인 필요)

  • get_cardlast_review·state를 로드하지 않아 재리뷰 시 FSRS 경과일 계산이 부정확할 수 있음 (naive/aware datetime 이슈 얽힘 — py-fsrs tz 동작 확인 후 처리).
  • review_log가 한 번도 기록되지 않음(개인 가중치 재학습 원천이 비어있음).

테스트

  • 프로덕션 배치 실측으로 refactor: Clean Architecture 구조로 전환 #1 재현(위 skipped=0). 수정 후엔 2일차부터 skipped 증가 기대.
  • ⚠️ 이 브랜치는 아직 EC2 미배포 — 머지 후 배포 필요(오늘밤 2시 크론은 미수정 코드로 도는 상태).

🤖 Generated with Claude Code

두 개의 프로덕션 버그 수정 (둘 다 infrastructure/repositories.py):

1. MySQLReviewCardRepository.save_card 가 last_review 를 저장하지 않아
   review_card.last_review 가 항상 NULL 로 남았다. find_review_targets 의
   멱등성 조건(rc.last_review IS NULL OR qs.submitted_at > rc.last_review)이
   항상 참이 되어 야간 배치가 매 실행마다 전 카드를 재리뷰(당일 재리뷰로
   처리 → FSRS stability 왜곡). 실측: 같은 날 재실행 시 skipped=0, updated=453.
   INSERT/UPDATE 에 last_review 추가.

2. MySQLEnrollmentQuizResolver.get_member_id 가 `enrollment WHERE id=%s` 로
   조회했으나 enrollment 테이블 PK 는 enrollment_id 이고 id 컬럼은 없음
   (V1__baseline.sql). "Unknown column 'id'" 로 유사문제 추천 경로 전체가
   실패했다. WHERE enrollment_id=%s 로 수정.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant