feat(pos): filtrar modelos a solo Norteamerica — elimina modelos de otros mercados
Lista de modelos por marca para Mexico/USA/Canada (36 marcas). Toyota: 625 → 236, Nissan: 499 → 138, Ford: 288 → 114, Chevrolet: 470 → 207, VW: 283 → 143, Honda: 223 → 117. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,8 @@ PERFORMANCE: vehicle_parts has 14B+ rows. Every query MUST:
|
||||
|
||||
import re
|
||||
|
||||
from services.na_models import is_na_model
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# VEHICLE HIERARCHY NAVIGATION
|
||||
@@ -54,10 +56,18 @@ def get_brands(master_conn, year_id=None):
|
||||
return [{'id_brand': r[0], 'name_brand': r[1]} for r in rows]
|
||||
|
||||
|
||||
def get_models(master_conn, brand_id, year_id=None):
|
||||
"""Get models for a brand that have MYE entries.
|
||||
If year_id is provided, only models available for that year."""
|
||||
def get_models(master_conn, brand_id, year_id=None, brand_name=None):
|
||||
"""Get models for a brand that have MYE entries, filtered to North America.
|
||||
If year_id is provided, only models available for that year.
|
||||
brand_name is used for NA filtering; looked up from DB if not provided."""
|
||||
cur = master_conn.cursor()
|
||||
|
||||
# Resolve brand_name for NA filter if not provided
|
||||
if not brand_name:
|
||||
cur.execute("SELECT name_brand FROM brands WHERE id_brand = %s", (brand_id,))
|
||||
row = cur.fetchone()
|
||||
brand_name = row[0] if row else ''
|
||||
|
||||
if year_id:
|
||||
cur.execute("""
|
||||
SELECT DISTINCT m.id_model, m.name_model
|
||||
@@ -76,7 +86,13 @@ def get_models(master_conn, brand_id, year_id=None):
|
||||
""", (brand_id,))
|
||||
rows = cur.fetchall()
|
||||
cur.close()
|
||||
return [{'id_model': r[0], 'name_model': r[1]} for r in rows]
|
||||
|
||||
# Filter to North America models only
|
||||
return [
|
||||
{'id_model': r[0], 'name_model': r[1]}
|
||||
for r in rows
|
||||
if is_na_model(brand_name, r[1])
|
||||
]
|
||||
|
||||
|
||||
def get_years(master_conn, model_id):
|
||||
|
||||
Reference in New Issue
Block a user