fix(tradein): SAVEPOINT-wrap cian snapshot write + harden log (#567)
This commit is contained in:
parent
b16935e679
commit
5794009840
1 changed files with 12 additions and 9 deletions
|
|
@ -260,16 +260,19 @@ def save_detail_enrichment(db: Session, listing_id: int, enrichment: DetailEnric
|
|||
"""),
|
||||
{"lid": listing_id},
|
||||
).fetchone()
|
||||
_snap_written = False
|
||||
if _snap_row is not None and _snap_row.price_rub is not None:
|
||||
try:
|
||||
upsert_listing_snapshot(
|
||||
db,
|
||||
listing_id=listing_id,
|
||||
price_rub=int(_snap_row.price_rub),
|
||||
price_per_m2=int(_snap_row.price_per_m2) if _snap_row.price_per_m2 else None,
|
||||
run_id=None,
|
||||
status="active",
|
||||
)
|
||||
with db.begin_nested():
|
||||
upsert_listing_snapshot(
|
||||
db,
|
||||
listing_id=listing_id,
|
||||
price_rub=int(_snap_row.price_rub),
|
||||
price_per_m2=int(_snap_row.price_per_m2) if _snap_row.price_per_m2 else None,
|
||||
run_id=None,
|
||||
status="active",
|
||||
)
|
||||
_snap_written = True
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"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,
|
||||
len(enrichment.price_changes),
|
||||
bool(enrichment.agent_profile),
|
||||
_snap_row is not None and _snap_row.price_rub is not None,
|
||||
_snap_written,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue