@@ -236,19 +236,12 @@ ORDER BY
236236
237237/**
238238 * Get all events in an endpoint type cluster
239- * Disabled events are not loaded into ENDPOINT_TYPE_EVENT table,
240- * so we need to load all events by joining DEVICE_TYPE_CLUSTER table
241239 *
242240 * @param {* } db
243241 * @param {* } endpointTypeClusterId
244- * @param {* } deviceTypeClusterId
245242 * @returns all events in an endpoint type cluster
246243 */
247- async function selectEventsByEndpointTypeClusterIdAndDeviceTypeClusterId (
248- db ,
249- endpointTypeClusterId ,
250- deviceTypeClusterId
251- ) {
244+ async function selectEventsByEndpointTypeClusterId ( db , endpointTypeClusterId ) {
252245 let rows = await dbApi . dbAll (
253246 db ,
254247 `
@@ -262,28 +255,28 @@ async function selectEventsByEndpointTypeClusterIdAndDeviceTypeClusterId(
262255 FROM
263256 EVENT
264257 JOIN
265- DEVICE_TYPE_CLUSTER
258+ ENDPOINT_TYPE_CLUSTER
266259 ON
267- EVENT.CLUSTER_REF = DEVICE_TYPE_CLUSTER.CLUSTER_REF
260+ EVENT.CLUSTER_REF = ENDPOINT_TYPE_CLUSTER.CLUSTER_REF
261+ AND
262+ ENDPOINT_TYPE_CLUSTER.ENDPOINT_TYPE_CLUSTER_ID = ?
268263 LEFT JOIN
269264 ENDPOINT_TYPE_EVENT
270265 ON
271266 EVENT.EVENT_ID = ENDPOINT_TYPE_EVENT.EVENT_REF
272267 AND
273- ENDPOINT_TYPE_EVENT.ENDPOINT_TYPE_CLUSTER_REF = ?
274- WHERE
275- DEVICE_TYPE_CLUSTER.DEVICE_TYPE_CLUSTER_ID = ?
268+ ENDPOINT_TYPE_EVENT.ENDPOINT_TYPE_CLUSTER_REF = ENDPOINT_TYPE_CLUSTER.ENDPOINT_TYPE_CLUSTER_ID
276269 ` ,
277- [ endpointTypeClusterId , deviceTypeClusterId ]
270+ [ endpointTypeClusterId ]
278271 )
279272 return rows . map ( dbMapping . map . endpointTypeEventExtended )
280273}
281274
282275exports . selectEventsByClusterId = selectEventsByClusterId
283276exports . selectAllEvents = selectAllEvents
284277exports . selectAllEventFields = selectAllEventFields
285- exports . selectEventsByEndpointTypeClusterIdAndDeviceTypeClusterId =
286- selectEventsByEndpointTypeClusterIdAndDeviceTypeClusterId
278+ exports . selectEventsByEndpointTypeClusterId =
279+ selectEventsByEndpointTypeClusterId
287280exports . selectEventFieldsByEventId = selectEventFieldsByEventId
288281exports . selectEndpointTypeEventsByEndpointTypeRefAndClusterRef =
289282 selectEndpointTypeEventsByEndpointTypeRefAndClusterRef
0 commit comments