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:
@@ -598,19 +598,23 @@ def _match_vin_to_catalog(master_conn, vin_info):
|
|||||||
@catalog_bp.route('/vehicle-brands', methods=['GET'])
|
@catalog_bp.route('/vehicle-brands', methods=['GET'])
|
||||||
@require_auth('catalog.view')
|
@require_auth('catalog.view')
|
||||||
def vehicle_brands():
|
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
|
Uses the same OEM_BRANDS_NA filter as the regular catalog so that
|
||||||
the 256M-row part_vehicle_preview materialized view.
|
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):
|
def _query(master):
|
||||||
cur = master.cursor()
|
cur = master.cursor()
|
||||||
try:
|
try:
|
||||||
cur.execute("""
|
cur.execute("""
|
||||||
SELECT id_brand, name_brand
|
SELECT id_brand, name_brand
|
||||||
FROM brands
|
FROM brands
|
||||||
|
WHERE name_brand = ANY(%s)
|
||||||
ORDER BY name_brand ASC
|
ORDER BY name_brand ASC
|
||||||
""")
|
""", (allowed,))
|
||||||
rows = cur.fetchall()
|
rows = cur.fetchall()
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'brands': [
|
'brands': [
|
||||||
|
|||||||
Reference in New Issue
Block a user