This commit is contained in:
Jake Kasper
2025-08-28 08:04:12 -05:00
parent 1ee3d2f572
commit e22cc10310
2 changed files with 42 additions and 5 deletions

View File

@@ -39,9 +39,11 @@ router.get('/product/:productId', validateParams(productIdParamSchema), async (r
const productId = req.params.productId;
const result = await pool.query(
`SELECT * FROM product_spreader_settings
WHERE product_id = $1
ORDER BY spreader_brand, spreader_model NULLS LAST, setting_value`,
`SELECT pss.*, ue.custom_name as equipment_name, ue.manufacturer, ue.model as equipment_model
FROM product_spreader_settings pss
LEFT JOIN user_equipment ue ON pss.equipment_id = ue.id
WHERE pss.product_id = $1
ORDER BY ue.custom_name NULLS LAST, pss.spreader_brand, pss.spreader_model NULLS LAST, pss.setting_value`,
[productId]
);
@@ -50,6 +52,11 @@ router.get('/product/:productId', validateParams(productIdParamSchema), async (r
data: {
settings: result.rows.map(row => ({
id: row.id,
equipmentId: row.equipment_id,
equipmentName: row.equipment_name,
equipmentManufacturer: row.manufacturer,
equipmentModel: row.equipment_model,
// Legacy fields
spreaderBrand: row.spreader_brand,
spreaderModel: row.spreader_model,
settingValue: row.setting_value,