feat(catalog): supplier catalog cleanup, fuzzy matching, and navigation fixes
- Cleaned 137+ fake engine-displacement models from supplier imports (v3/v4 scripts: Chevrolet, Ford, Chrysler, Dodge, Jeep, Nissan, etc.) - Removed 1,251+ corrupted models (INT. prefixes, year-suffix, torque specs, empty names, trailing-year variants) - Migrated supplier tables to master DB (supplier_catalog, supplier_catalog_compat, supplier_catalog_interchange) - Fixed _get_mye_ids_with_parts() to query supplier_catalog_compat from master DB so supplier-only vehicles appear for all tenants - Added fuzzy model matcher with parenthesis stripping, noise suffix removal, compact matching, prefix/substring fallback, model aliases, and ±3 year proximity - Matched compat rows: KEEP GREEN +14,152, KNADIAN +3,021, VAZLO +127,500, LUK +477, RAYBESTOS +1,743 - Added KNADIAN catalog importer with year-range expansion and future-year filtering - Added VAZLO catalog importer with position parsing and SKU-in-model cleanup - Added Keep Green, LUK, Yokomitsu, Raybestos catalog importers - Cache clearing after cleanups (_classify_cache_*, nexus:mye_ids:*, nexus:brand_mye_counts:*) Final match rates: - KEEP GREEN: 90.3% - VAZLO: 93.6% - YOKOMITSU: 100.0% - KNADIAN: 57.4% - LUK: 51.0% - RAYBESTOS: 55.9%
This commit is contained in:
14
pos/tasks.py
14
pos/tasks.py
@@ -218,6 +218,17 @@ def process_meli_webhook_task(self, tenant_id: int, topic: str, resource: str):
|
||||
# Re-use fetch_and_save_orders by passing the order directly
|
||||
# For simplicity, trigger a full sync for recent orders
|
||||
return meli_svc.fetch_and_save_orders(conn)
|
||||
|
||||
if topic.startswith("questions"):
|
||||
# Fetch single question and upsert locally
|
||||
if resource:
|
||||
question_id = resource.split("/")[-1]
|
||||
try:
|
||||
meli_svc.fetch_question_from_ml(conn, question_id)
|
||||
return {'ok': True, 'topic': topic, 'question_id': question_id}
|
||||
except Exception as qe:
|
||||
return {'ok': False, 'topic': topic, 'error': str(qe)}
|
||||
|
||||
return {'ok': True, 'topic': topic}
|
||||
except Exception as e:
|
||||
return {'error': str(e)}
|
||||
@@ -270,7 +281,7 @@ def sync_vehicle_compatibility_task(self, tenant_id, item_id, part_number, name,
|
||||
|
||||
|
||||
@celery.task(bind=True)
|
||||
def publish_meli_items_task(self, tenant_id: int, inventory_ids: list, category_id: str, listing_type: str = "gold_special", shipping_mode: str = "me2", custom_data: dict = None):
|
||||
def publish_meli_items_task(self, tenant_id: int, inventory_ids: list, category_id: str, listing_type: str = "gold_special", shipping_mode: str = "me2", custom_data: dict = None, base_url: str = None):
|
||||
"""Publish inventory items to MercadoLibre asynchronously."""
|
||||
from services import marketplace_external_service as meli_svc
|
||||
from tenant_db import get_tenant_conn
|
||||
@@ -284,6 +295,7 @@ def publish_meli_items_task(self, tenant_id: int, inventory_ids: list, category_
|
||||
listing_type_id=listing_type,
|
||||
shipping_mode=shipping_mode,
|
||||
custom_data=custom_data or {},
|
||||
base_url=base_url,
|
||||
)
|
||||
return result
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user