Phase 1-3 of decoupling: - path_setup.py adds project root to sys.path - Market-owned models in market/models/ (market, market_place) - All imports updated: shared.infrastructure, shared.db, shared.browser, etc. - MarketPlace uses container_type/container_id instead of post_id FK Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
30 lines
938 B
Python
30 lines
938 B
Python
# at top of persist_snapshot.py:
|
|
from typing import List
|
|
|
|
from typing import Dict, List
|
|
|
|
from models.market import (
|
|
LinkError,
|
|
LinkExternal,
|
|
)
|
|
from shared.db.session import get_session
|
|
|
|
# --- Models are unchanged, see original code ---
|
|
|
|
# ---------------------- Helper fns called from scraper ------------------------
|
|
|
|
|
|
|
|
async def save_link_reports(link_errors: List[Dict], link_externals: List[Dict]) -> None:
|
|
async with get_session() as session:
|
|
for e in link_errors:
|
|
session.add(LinkError(
|
|
product_slug=e.get("product"), href=e.get("href"), text=e.get("text"),
|
|
top=e.get("top"), sub=e.get("sub"), target_slug=e.get("target_slug"), type=e.get("type"),
|
|
))
|
|
for e in link_externals:
|
|
session.add(LinkExternal(
|
|
product_slug=e.get("product"), href=e.get("href"), text=e.get("text"), host=e.get("host"),
|
|
))
|
|
await session.commit()
|