fix: repair Rentman equipment sync with real API field mapping
- Map real Rentman fields: price -> rental_price, folder -> category/subcategory (resolved via folder hierarchy to top-level categories), code -> number, shop_description_long (fallback short/external_remark) -> description (HTML stripped) - Sync only in_shop items; exclude archived/temporary from public catalog - Extract known brands from equipment names (d&b, Shure, Pioneer, ...) - Build specifications from physical fields (power, weight, dimensions) - Persist equipment images in docker volume (survive redeploys) - Router: filter available items, add price_asc/price_desc sorting - Frontend: show prices in catalog card, detail page and cart with per-day subtotal; price sorting options - Tests: use real Rentman field names in fixtures, mock folder_map
This commit is contained in:
@@ -30,8 +30,8 @@ async def list_equipment(
|
||||
if cached:
|
||||
return cached
|
||||
|
||||
query = select(EquipmentCache)
|
||||
count_query = select(func.count(EquipmentCache.id))
|
||||
query = select(EquipmentCache).where(EquipmentCache.available == True) # noqa: E712
|
||||
count_query = select(func.count(EquipmentCache.id)).where(EquipmentCache.available == True) # noqa: E712
|
||||
|
||||
if search:
|
||||
query = query.where(EquipmentCache.name.ilike(f"%{search}%"))
|
||||
@@ -42,6 +42,10 @@ async def list_equipment(
|
||||
|
||||
if sort == "name_desc":
|
||||
query = query.order_by(EquipmentCache.name.desc())
|
||||
elif sort == "price_asc":
|
||||
query = query.order_by(EquipmentCache.rental_price.asc().nulls_last(), EquipmentCache.name.asc())
|
||||
elif sort == "price_desc":
|
||||
query = query.order_by(EquipmentCache.rental_price.desc().nulls_last(), EquipmentCache.name.asc())
|
||||
else:
|
||||
query = query.order_by(EquipmentCache.name.asc())
|
||||
|
||||
@@ -70,7 +74,9 @@ async def list_categories(db: AsyncSession = Depends(get_db)) -> Any:
|
||||
if cached:
|
||||
return cached
|
||||
result = await db.execute(
|
||||
select(EquipmentCache.category).distinct().where(EquipmentCache.category.isnot(None))
|
||||
select(EquipmentCache.category).distinct().where(
|
||||
EquipmentCache.category.isnot(None), EquipmentCache.available == True # noqa: E712
|
||||
)
|
||||
)
|
||||
categories = [row[0] for row in result.fetchall() if row[0]]
|
||||
await cache.set("equipment:categories", categories, ttl=3600)
|
||||
|
||||
Reference in New Issue
Block a user