feat(store): detect overlapping maintenance windows
Warn via log when creating a maintenance window that overlaps with an existing one for the same monitor, parent group, or global scope. Handles both timed and indefinite windows.
This commit was merged in pull request #151.
This commit is contained in:
@@ -256,6 +256,11 @@ func (m *Model) submitMaintForm() tea.Cmd {
|
||||
st := m.store
|
||||
m.state = stateDashboard
|
||||
return writeCmd("Add maintenance window", func() error {
|
||||
return st.AddMaintenanceWindow(context.Background(), mw)
|
||||
ctx := context.Background()
|
||||
overlaps, _ := st.GetOverlappingMaintenanceWindows(ctx, mw.MonitorID, mw.StartTime, mw.EndTime)
|
||||
if len(overlaps) > 0 {
|
||||
_ = st.SaveLog(ctx, fmt.Sprintf("Overlap: new window %q overlaps with existing %q", mw.Title, overlaps[0].Title))
|
||||
}
|
||||
return st.AddMaintenanceWindow(ctx, mw)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user