Add discovery search history with auto-save, fix timeout causing search failure
- Save every search result to DB for later review - Add '搜索历史' tab with timeline view, load/delete records - Raise discovery search timeout from 30s to 120s (Bing Puppeteer needs ~40s) - Reduce search queries from 4 to 3 for faster response - New model: DiscoveryRecord (user_id, product, market, companies JSON) - API: POST/GET/DELETE /api/v1/discovery/records - Migration: discovery_records table
This commit is contained in:
@@ -16,6 +16,7 @@ from .certification import Certification, CertType, CertStatus
|
||||
from .invoice import Invoice, InvoiceType, InvoiceStatus
|
||||
from .referral import ReferralCode, Referral
|
||||
from .search_provider import SearchProvider
|
||||
from .discovery_record import DiscoveryRecord
|
||||
|
||||
__all__ = [
|
||||
"User", "Product",
|
||||
@@ -36,4 +37,5 @@ __all__ = [
|
||||
"Invoice", "InvoiceType", "InvoiceStatus",
|
||||
"ReferralCode", "Referral",
|
||||
"SearchProvider",
|
||||
"DiscoveryRecord",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from sqlalchemy import Column, String, DateTime, Text
|
||||
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
||||
from datetime import datetime
|
||||
from app.database import Base
|
||||
import uuid
|
||||
|
||||
|
||||
class DiscoveryRecord(Base):
|
||||
__tablename__ = "discovery_records"
|
||||
|
||||
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
user_id = Column(UUID(as_uuid=True), nullable=False, index=True)
|
||||
product = Column(String(500), nullable=False)
|
||||
market = Column(String(200), default="")
|
||||
companies = Column(JSONB, default=[])
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
Reference in New Issue
Block a user