feat(tradein-scrapers): parse listing_date from Avito + Yandex #508
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#508
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/tradein-listing-date-avito-yandex"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
6/10 analogs в
a0a0b820-…пришли сlisting_date=null,days_on_market=null. →est_days_on_market=nullна UI.Fix
avito.py:_parse_relative_date()regex для relative dates (N дней/недель/месяцев назад). Извлекаем изdata-marker=item-date+ fallback на полный текст карточки.yandex_helpers.py: новаяparse_listing_date()— absolute RU date (9 мая 2026) + relative fallback (N дней назад).yandex_realty.py: заменяемparse_ru_date()→parse_listing_date()(backward compat, расширяет coverage).cian.pyне тронут — уже парситlisting_dateизaddedTimestamp.test_avito_relative_date.py: days/weeks/hours/None cases.Notes
дн[яей]не матчит «дней» — заменён надн(?:я|ей?)).data-marker=item-dateотсутствует или изменил структуру.Deep Code Review — PR #508
Status: APPROVE
Files: 4 (P0: 0, P1: 2 scrapers, P2: 1 helper, P3: 1 test) · Lines: +126 / -3 · SHA
628d8adSummary
Narrow, well-scoped fix for documented data-quality gap (Decision_TradeIn_DataQuality_8PR_Roadmap →
est_days_on_market=nullroot cause). Adds relative-date parser (N дней/недель/месяцев/часов назад) for Avito + Yandex SERP cards, plus absolute-RU-date fallback chain for Yandex. Zero regression risk on existing fields.Correctness 🎯
5 лет назадdoes NOT match (Avito caps at «год»; acceptable gap).avito.py(item-date→item-date-info→ full-card-text search) is sane; primarydata-marker="item-date"runs first so fallback only triggers on selector miss.parse_listing_date()preserves backward compat: triesparse_ru_date()first (absolute), then relative — no Yandex absolute-date regression.days_on_marketis downstream-computed asNOW() - listing_date, so the convention is consistent with how the metric is consumed.Pre-existing concern (NOT introduced by this PR)
base.pyUPSERTON CONFLICT DO UPDATEdoes not refreshlisting_date— pre-fix rows withlisting_date=nullwill stay null even after re-scrape with new logic. Backfill task needed (separate PR; not a blocker for this one).Architecture 🏗
_REL_DATE_RE+ unit-prefix table duplicated verbatim inavito.pyandyandex_helpers.py. Could be consolidated into a shared helper. Non-blocking — small, isolated, and the two copies have already been kept in sync.Tests 🧪
test_avito_relative_date.pycovers 4 cases (days/weeks/hours/None+empty+random). Adequate primary coverage.parse_listing_date()and_parse_relative_date_yandex()have NO dedicated tests (logic is structurally identical to Avito's, but two copies = two test suites ideally). Recommend addingtest_yandex_helpers.py::test_parse_listing_date_*in a follow-up.date.today()— micro flake risk at UTC midnight, acceptable for unit scope.Security 🔒 / Performance ⚡
Conventions 📋
from __future__ import annotations✅, type hints ✅,dict[str, int]3.12 syntax ✅, ruff-clean line lengths ✅.yandex_realty.pyimport switchparse_ru_date → parse_listing_dateis the only call-site change — clean.Vault cross-ref 📚
decisions/Decision_TradeIn_DataQuality_8PR_Roadmap(item 3:est_days_on_market=nullUX fallback). This PR fixes upstream root cause, restoring real values instead of fallback text.Recommended follow-ups (non-blocking)
_REL_DATE_RE/_UNIT_DAYSinto a single shared helper.test_yandex_helpers.py::test_parse_listing_date_*cases.listing_date=null(separate PR).ON CONFLICT DO UPDATEto refreshlisting_datewhen it transitions from null → value.Verdict: APPROVE — merge any-scope.