Skip to content

feat: 실거래가 데이터 추출 스케줄링 및 배치 적재 구현 - #3

Merged
ehdrb92 merged 1 commit into
develop/2from
feature/scheduled-data-extraction
Aug 30, 2026
Merged

ehdrb92 merged 1 commit into
develop/2from
feature/scheduled-data-extraction

Conversation

@ehdrb92

@ehdrb92 ehdrb92 commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • scripts/results의 월별 RTMS JSON(매매/전월세 x 아파트/오피스텔/연립다세대/단독다가구, 8개 소스)을 읽어 SaleTransaction/RentTransaction 스키마에 맞게 변환한 뒤 배치 upsert하는 로직을 api/app/main.py에 추가
  • APScheduler(AsyncIOScheduler)로 매일 04:00에 추출 작업이 실행되도록 스케줄링
  • 적재 검증(Docker postgres:17) 중 기존 복합 UniqueConstraint가 nullable 컬럼(단독·다가구는 jibun/building_name/floor/exclusive_use_area가 항상 NULL) 때문에 dedup이 동작하지 않던 문제를 발견 → 행 전체 내용을 해싱한 dedup_hash 컬럼 기반 UNIQUE로 교체(api/app/model/prop_transaction.py)

Test plan

  • ruff format . / ruff check . 통과
  • Docker postgres:17 컨테이너에 3개월(202606~202608) x 8소스 샘플을 두 번 연속 적재하여 idempotency(재실행 시 중복 없음) 확인 — SINGLE_MULTI 포함 모든 property_type에서 count(*) == count(DISTINCT dedup_hash) 일치
  • TestClient로 FastAPI 앱을 기동해 lifespan(스케줄러 시작/종료) 및 /health 정상 동작 확인
  • 전체 이력(2006~2026) 백필은 아직 미실행 — 필요 시 별도 진행

🤖 Generated with Claude Code

https://claude.ai/code/session_01YDnVFzm6DW7CjG9hXN3QeV

scripts/results의 월별 RTMS JSON(8개 소스: 매매/전월세 x 아파트/오피스텔/
연립다세대/단독다가구)을 읽어 SaleTransaction/RentTransaction 스키마에
맞게 변환한 뒤 배치 upsert하는 작업을 APScheduler로 매일 04:00에
실행하도록 main.py에 추가.

적재 검증 중 UniqueConstraint에 포함된 nullable 컬럼(jibun, building_name,
floor, exclusive_use_area)이 단독·다가구 타입에서 항상 NULL이라 PostgreSQL의
NULL != NULL 규칙으로 인해 dedup이 동작하지 않던 문제를 발견하여, 복합
자연키 대신 행 전체 내용을 해싱한 dedup_hash 컬럼 기반 UNIQUE로 교체.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YDnVFzm6DW7CjG9hXN3QeV
@sonarqubecloud

Copy link
Copy Markdown

@ehdrb92
ehdrb92 merged commit b7810e2 into develop/2 Aug 30, 2026
2 checks passed
@ehdrb92
ehdrb92 deleted the feature/scheduled-data-extraction branch August 31, 2026 13:06
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