- Parallel execution: search() and get_completed_sales() now run
concurrently via ThreadPoolExecutor — each gets its own Store/SQLite
connection for thread safety. First cold search time ~halved.
- Pagination: SearchFilters.pages (default 1) controls how many eBay
result pages are fetched. Both search and sold-comps support up to 3
parallel Playwright sessions per call (capped to avoid Xvfb overload).
UI: segmented 1/2/3/5 pages selector in filter sidebar with cost hint.
- True median: get_completed_sales() now averages the two middle values
for even-length price lists instead of always taking the lower bound.
- Fix suspicious_price false positive: aggregator now checks
signal_scores.get("price_vs_market") == 0 (pre-None-substitution)
so listings without market data are never flagged as suspicious.
- Fix title pollution: scraper strips eBay's hidden screen-reader span
("Opens in a new window or tab") from listing titles via regex.
Lazy-imports playwright/playwright_stealth inside _get() so pure
parsing functions are importable without the full browser stack.
- Tests: 48 pass on host (scraper tests now runnable without Docker),
new regression guards for all three bug fixes.
28 lines
925 B
Python
28 lines
925 B
Python
"""PlatformAdapter abstract base and shared types."""
|
|
from __future__ import annotations
|
|
from abc import ABC, abstractmethod
|
|
from dataclasses import dataclass, field
|
|
from typing import Optional
|
|
from app.db.models import Listing, Seller
|
|
|
|
|
|
@dataclass
|
|
class SearchFilters:
|
|
max_price: Optional[float] = None
|
|
min_price: Optional[float] = None
|
|
condition: Optional[list[str]] = field(default_factory=list)
|
|
location_radius_km: Optional[int] = None
|
|
pages: int = 1 # number of result pages to fetch (48 listings/page)
|
|
|
|
|
|
class PlatformAdapter(ABC):
|
|
@abstractmethod
|
|
def search(self, query: str, filters: SearchFilters) -> list[Listing]: ...
|
|
|
|
@abstractmethod
|
|
def get_seller(self, seller_platform_id: str) -> Optional[Seller]: ...
|
|
|
|
@abstractmethod
|
|
def get_completed_sales(self, query: str) -> list[Listing]:
|
|
"""Fetch recently completed/sold listings for price comp data."""
|
|
...
|