add quiet hours to silence alerts during specific time periods (#265)

This commit is contained in:
henrygd
2025-11-24 17:35:28 -05:00
parent 26d367b188
commit 888b4a57e5
11 changed files with 1220 additions and 57 deletions

View File

@@ -498,6 +498,10 @@ func (rm *RecordManager) DeleteOldRecords() {
if err != nil {
return err
}
err = deleteOldQuietHours(txApp)
if err != nil {
return err
}
return nil
})
}
@@ -591,6 +595,17 @@ func deleteOldContainerRecords(app core.App) error {
return nil
}
// Deletes old quiet hours records where end date has passed
func deleteOldQuietHours(app core.App) error {
now := time.Now().UTC()
_, err := app.DB().NewQuery("DELETE FROM quiet_hours WHERE type = 'one-time' AND end < {:now}").Bind(dbx.Params{"now": now}).Execute()
if err != nil {
return err
}
return nil
}
/* Round float to two decimals */
func twoDecimals(value float64) float64 {
return math.Round(value*100) / 100