fix(catalog): filter vehicle-brands to North America OEM brands only

/vehicle-brands now uses get_brands_for_mode('oem') to return the same
36 North American brands (Mexico/USA/Canada) as the regular catalog flow,
instead of all 619 brands in the database.
This commit is contained in:
2026-05-14 21:38:36 +00:00
parent c6b3ca9bdf
commit 4d6a7d9f32

View File

@@ -598,19 +598,23 @@ def _match_vin_to_catalog(master_conn, vin_info):
@catalog_bp.route('/vehicle-brands', methods=['GET'])
@require_auth('catalog.view')
def vehicle_brands():
"""Return vehicle brands for brand-first catalog browsing.
"""Return North American vehicle brands for brand-first catalog browsing.
Returns all brands from the brands table (fast) rather than scanning
the 256M-row part_vehicle_preview materialized view.
Uses the same OEM_BRANDS_NA filter as the regular catalog so that
the brand list is consistent across both navigation modes.
"""
from services.catalog_modes import get_brands_for_mode
allowed = list(get_brands_for_mode('oem'))
def _query(master):
cur = master.cursor()
try:
cur.execute("""
SELECT id_brand, name_brand
FROM brands
WHERE name_brand = ANY(%s)
ORDER BY name_brand ASC
""")
""", (allowed,))
rows = cur.fetchall()
return jsonify({
'brands': [