Skip to content

직전 거래액이 0원인 단지를 변동 단지에서 제외 - #14

Merged
ehdrb92 merged 1 commit into
developfrom
fix/price-movers-zero-previous-amount
Nov 22, 2026
Merged

ehdrb92 merged 1 commit into
developfrom
fix/price-movers-zero-previous-amount

Conversation

@ehdrb92

@ehdrb92 ehdrb92 commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

배경

market_price_movers 갱신 SQL은 단지별 최근 거래와 직전 거래를 비교해 변동률을 (최근 - 직전) * 100 / 직전으로 계산합니다. 거래액이 0원인 행을 막는 제약이 없어서, 직전 거래액이 0원인 단지가 하나만 있어도 0 나누기 오류가 나고 갱신 전체가 실패합니다.

변경

  • airflow/dags/rtms/db.py: 분모를 NULLIF(previous_deal_amount, 0)으로 바꿨습니다. 해당 단지는 change_rate가 NULL이 되어 급등(> 0)·급락(< 0) 조건에 걸리지 않고 결과에서만 빠집니다.
  • airflow/tests/test_rtms_daily_db.py: 직전 거래액이 0원인 zero_previous 케이스를 test_price_movers_exclude_ineligible_groups에 추가했습니다.

확인

  • uv run ruff format --check ., uv run ruff check ., airflow/에서 uv run pyright 통과
  • airflow/에서 uv run pytest tests/test_rtms_daily_db.py 28개 통과 (임시 Postgres 18 컨테이너 사용)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Prevented price-mover calculations from failing when the previous transaction amount is zero. Such transactions are excluded from mover results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The market price mover calculation now handles a zero previous deal amount without division by zero. The ineligible-group test includes a group with that amount and verifies that no movers are loaded.

Changes: Price mover calculation

Layer / File(s) Summary
Guard price-change calculation
airflow/dags/rtms/db.py, airflow/tests/test_rtms_daily_db.py
The SQL uses NULLIF to return a NULL change rate when the previous deal amount is zero. The test adds such a group to the ineligible cases and checks that no movers are loaded.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Possibly related PRs

  • f-lab-edu/PropTrend#11: Introduced the scheduled refresh and market_price_movers calculation that this change updates.
Merge Risk: Minimal · up to f8e66

This fix stops the price-mover refresh from failing when a complex's previous deal amount is zero. Such complexes are excluded from the movers list. The change is small, covered by a new test case, and carries no identified merge risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 제목은 직전 거래액이 0원인 단지를 변동 단지 목록에서 제외한다는 이 PR의 주요 변경 내용을 설명한다. 변경 사항은 market_price_movers 갱신 시 0 나누기 오류를 막기 위해 분모를 NULLIF(previous_deal_amount, 0)로 바꾸는 것이고, 테스트에도 zero_previous 사례가 추가되었다. 제목과 변경 내용이 직접 일치…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

제목은 직전 거래액이 0원인 단지를 변동 단지 목록에서 제외한다는 이 PR의 주요 변경 내용을 설명한다. 변경 사항은 market_price_movers 갱신 시 0 나누기 오류를 막기 위해 분모를 NULLIF(previous_deal_amount, 0)로 바꾸는 것이고, 테스트에도 zero_previous 사례가 추가되었다. 제목과 변경 내용이 직접 일치하므로 통과로 판단한다.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0e78dadd-fbf0-449a-9b66-e3fa30470958
Commits

Reviewing files that changed from the base of the PR and between 685b49e and f8e66cb.

Files selected for processing: 2

  • airflow/dags/rtms/db.py
  • airflow/tests/test_rtms_daily_db.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@sonarqubecloud

Copy link
Copy Markdown

@ehdrb92
ehdrb92 merged commit c55178e into develop Nov 22, 2026
4 checks passed
@ehdrb92
ehdrb92 deleted the fix/price-movers-zero-previous-amount branch November 23, 2026 12:56
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