feature: Improve dashboard functionality
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
export function isNotifiableCriticalAlert(alert) {
|
||||
return (
|
||||
alert.severity === 'Critical'
|
||||
&& (alert.status === 'Open' || alert.status === 'Escalated')
|
||||
)
|
||||
}
|
||||
|
||||
export function detectNewCriticalAlerts(alerts, lastSeenIds, seeded = false) {
|
||||
const criticalOpen = alerts.filter(isNotifiableCriticalAlert)
|
||||
const criticalIds = criticalOpen.map(alert => alert.id)
|
||||
|
||||
if (!seeded) {
|
||||
return { newAlerts: [], nextSeenIds: criticalIds, seeded: true }
|
||||
}
|
||||
|
||||
const seen = new Set(lastSeenIds)
|
||||
const newAlerts = criticalOpen.filter(alert => !seen.has(alert.id))
|
||||
return { newAlerts, nextSeenIds: criticalIds, seeded: true }
|
||||
}
|
||||
Reference in New Issue
Block a user