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},
|
{"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:
|
||||||
upsert_listing_snapshot(
|
with db.begin_nested():
|
||||||
db,
|
upsert_listing_snapshot(
|
||||||
listing_id=listing_id,
|
db,
|
||||||
price_rub=int(_snap_row.price_rub),
|
listing_id=listing_id,
|
||||||
price_per_m2=int(_snap_row.price_per_m2) if _snap_row.price_per_m2 else None,
|
price_rub=int(_snap_row.price_rub),
|
||||||
run_id=None,
|
price_per_m2=int(_snap_row.price_per_m2) if _snap_row.price_per_m2 else None,
|
||||||
status="active",
|
run_id=None,
|
||||||
)
|
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,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue