fixing api history event alarm

This commit is contained in:
2025-10-28 12:24:52 +07:00
parent aa8aad94cf
commit d96cbd5e19

View File

@@ -93,16 +93,9 @@ const getHistoryEventDb = async (searchParams = {}) => {
const queryText = ` const queryText = `
SELECT SELECT
COUNT(*) OVER() AS total_data, COUNT(*) OVER() AS total_data,
a.*, a.*,
b.tag_name,
b.tag_number,
b.lim_low_crash,
b.lim_low,
b.lim_high,
b.lim_high_crash,
c.status_color c.status_color
FROM alarm_history a FROM event_alarm a
LEFT JOIN m_tags b ON a.tagnum = b.tag_number AND b.deleted_at IS NULL
LEFT JOIN m_status c ON a.status = c.status_number AND c.deleted_at IS NULL LEFT JOIN m_status c ON a.status = c.status_number AND c.deleted_at IS NULL
WHERE a.datetime IS NOT NULL WHERE a.datetime IS NOT NULL
${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""}