gendesign/tradein-mvp/backend/app/tasks
bot-backend 46db7ebcba feat(tradein): ppm2-tier segmentation of asking->sold ratio pool, flag-gated (#928)
Add ppm2-tier (low/mid/high) asking->sold ratio lookup behind
tier_aware_ratio_enabled feature flag (default OFF). Flag-OFF path
remains byte-identical to pre-#928 behavior.

Migration 098 (additive, idempotent):
- asking_to_sold_tier_bounds: 33.33/66.67 pct ppm2 bounds per rooms_bucket
- asking_to_sold_ratios_tiered: per-tier ratio + 'all' aggregates + global -1
  Parallel table to avoid fetchone() regression on asking_to_sold_ratios.

Task (asking_to_sold_ratio.py):
- Extends recompute_asking_to_sold_ratios with tiered DELETE + re-derive
  in same transaction (atomic with old table refresh).
- Two new counters: tiered_rows_written, tier_bounds_written.

Config (config.py):
- tier_aware_ratio_enabled: bool = False  (feature flag, ENV: TIER_AWARE_RATIO_ENABLED)
- tier_ratio_shrink_k: int = 150  (empirical-Bayes shrink K, ENV: TIER_RATIO_SHRINK_K)

Estimator (estimator.py):
- _get_asking_sold_ratio gains anchor_ppm2 param (default None, backward-compat).
- Cache key changed from int to tuple[int, str|None] (bucket, tier).
- Flag-ON path: bounds lookup -> tier assign -> shrunk ratio w/ Bayes shrink.
- Fallback chain: tier -> 'all' -> global_all -> (None, None).

Tests:
- tests/services/test_asking_sold_tier_ratio.py: 8 new unit tests.
- tests/test_asking_to_sold_ratio.py: updated FakeDB (8 execute calls) + counter assertions.

Refs #928
2026-05-31 23:58:46 +03:00
..
__init__.py feat(tradein): search matview + indexes (Phase 3.1) (#469) 2026-05-23 14:01:18 +00:00
asking_to_sold_ratio.py feat(tradein): ppm2-tier segmentation of asking->sold ratio pool, flag-gated (#928) 2026-05-31 23:58:46 +03:00
cian_history_backfill.py feat(tradein): houses.cian_zhk_url column + backfill (#568) (#627) 2026-05-28 13:57:43 +00:00
deactivate_stale_avito.py feat(tradein): nightly task to deactivate stale avito listings (#759) (#862) 2026-05-31 07:19:37 +00:00
geocode_missing.py feat(estimator): exclude city-centroid listings from radius analogs (Refs #769 Part E) 2026-05-30 21:22:21 +03:00
listing_source_snapshot.py feat(tradein): per-source listing price history — schema + daily snapshot (#570) (#646) 2026-05-29 12:18:04 +00:00
refresh_search_matview.py feat(tradein): search matview + indexes (Phase 3.1) (#469) 2026-05-23 14:01:18 +00:00
rosreestr_quarter_poll.py feat(tradein): scheduled monthly Rosreestr new-quarter poll → ingest alert (#888) (#894) 2026-05-31 13:13:55 +00:00
sber_index_pull.py feat(tradein): СберИндекс monthly city-level price index pull (#887, data-layer) (#890) 2026-05-31 12:44:56 +00:00
yandex_address_backfill.py feat(tradein): schedule yandex address backfill task (#855) (#866) 2026-05-31 07:31:10 +00:00