fix(tradein): SAVEPOINT-wrap cian snapshot write + harden log (#567)

This commit is contained in:
Light1YT 2026-05-28 18:43:58 +05:00
parent b16935e679
commit 5794009840

View file

@ -260,8 +260,10 @@ def save_detail_enrichment(db: Session, listing_id: int, enrichment: DetailEnric
"""), """),
{"lid": listing_id}, {"lid": listing_id},
).fetchone() ).fetchone()
_snap_written = False
if _snap_row is not None and _snap_row.price_rub is not None: if _snap_row is not None and _snap_row.price_rub is not None:
try: try:
with db.begin_nested():
upsert_listing_snapshot( upsert_listing_snapshot(
db, db,
listing_id=listing_id, listing_id=listing_id,
@ -270,6 +272,7 @@ def save_detail_enrichment(db: Session, listing_id: int, enrichment: DetailEnric
run_id=None, run_id=None,
status="active", status="active",
) )
_snap_written = True
except Exception as exc: except Exception as exc:
logger.warning( logger.warning(
"save_detail_enrichment: snapshot write failed listing_id=%s: %s", "save_detail_enrichment: snapshot write failed listing_id=%s: %s",
@ -351,5 +354,5 @@ def save_detail_enrichment(db: Session, listing_id: int, enrichment: DetailEnric
listing_id, listing_id,
len(enrichment.price_changes), len(enrichment.price_changes),
bool(enrichment.agent_profile), bool(enrichment.agent_profile),
_snap_row is not None and _snap_row.price_rub is not None, _snap_written,
) )