fix: include latest_image_id in patients query — fix /api/images/undefined/thumbnail
continuous-integration/webhook Deploy concluído (VPS4)

This commit is contained in:
VPS 4 Deploy Agent
2026-05-30 17:46:47 +02:00
parent 83f4b708ee
commit e232a81d66
+4 -2
View File
@@ -148,6 +148,9 @@ router.get('/patients', async (req, res) => {
MAX(client_name) AS client_name,
COUNT(*) AS image_count,
MAX(created_at) AS last_date,
(SELECT id FROM images i2
WHERE i2.patient_name = images.patient_name AND i2.enabled = ${enabledVal}
ORDER BY i2.created_at DESC LIMIT 1) AS latest_image_id,
(SELECT COALESCE(thumb_filename, filename) FROM images i2
WHERE i2.patient_name = images.patient_name AND i2.enabled = ${enabledVal}
ORDER BY i2.created_at DESC LIMIT 1) AS thumb_filename
@@ -159,9 +162,8 @@ router.get('/patients', async (req, res) => {
params
);
// Lazy-load URLs para thumbnails (carrega em paralelo quando o frontend chamar)
for (const row of rows) {
row.thumb_url = row.thumb_filename ? `/api/images/${row.id}/thumbnail` : '';
row.thumb_url = row.latest_image_id ? `/api/images/${row.latest_image_id}/thumbnail` : '';
}
res.json(rows);