From cbc7eadbd898404ddcab56ade16702bbf6be549e Mon Sep 17 00:00:00 2001 From: Alfredo Cardigliano Date: Thu, 2 Feb 2023 11:00:47 +0100 Subject: [PATCH] Fix engaged alerts reported in all tab --- scripts/lua/modules/alert_store/alert_store.lua | 2 +- scripts/lua/modules/alert_store/all_alert_store.lua | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/lua/modules/alert_store/alert_store.lua b/scripts/lua/modules/alert_store/alert_store.lua index d82753dec1..b0e0cc89d2 100644 --- a/scripts/lua/modules/alert_store/alert_store.lua +++ b/scripts/lua/modules/alert_store/alert_store.lua @@ -1020,12 +1020,12 @@ function alert_store:select_engaged(filter) -- Sort and filtering for idx, alert in pairs(alerts) do - -- Exclude alerts falling outside requested time ranges local tstamp = tonumber(alert.tstamp) -- Engaged alerts are currently active, ignore begin epoch -- if self._epoch_begin and tstamp < self._epoch_begin then goto continue end + -- Exclude alerts falling outside requested time ranges if self._epoch_end and tstamp > self._epoch_end then goto continue end if self._subtype and alert.subtype ~= self._subtype then goto continue end diff --git a/scripts/lua/modules/alert_store/all_alert_store.lua b/scripts/lua/modules/alert_store/all_alert_store.lua index f00e45a8ce..bcc6d33ae4 100644 --- a/scripts/lua/modules/alert_store/all_alert_store.lua +++ b/scripts/lua/modules/alert_store/all_alert_store.lua @@ -62,9 +62,12 @@ end function all_alert_store:__add_alert_stats(alert, alerts_by_entity, alerts_by_entity_flat) local entity_id = alert.entity_id - -- Exclude alerts falling outside requested time ranges local tstamp = tonumber(alert.tstamp) - if self._epoch_begin and tstamp < self._epoch_begin then return end + + -- Engaged alerts are currently active, ignore begin epoch + --if self._epoch_begin and tstamp < self._epoch_begin then return end + + -- Exclude alerts falling outside requested time ranges if self._epoch_end and tstamp > self._epoch_end then return end if not alerts_by_entity[entity_id] then @@ -111,7 +114,6 @@ end --@return Selected engaged alerts, and the total number of engaged alerts function all_alert_store:select_engaged(filter) -- No filter, get all active interface alerts - local alerts local alerts_by_entity_flat = {} local alerts_by_entity = {} @@ -119,7 +121,8 @@ function all_alert_store:select_engaged(filter) local sort_2_col = {} -- Compute alert stats for this interface - alerts = interface.getEngagedAlerts() + local alerts = interface.getEngagedAlerts() + for _, alert in pairs(alerts) do self:__add_alert_stats(alert, alerts_by_entity, alerts_by_entity_flat) end