aboutsummaryrefslogtreecommitdiff
path: root/internal/storage
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-19 04:38:08 -0800
committerFuwn <[email protected]>2026-01-19 04:38:08 -0800
commit2f2549d6df7300b04a4550dc060a3d7f684a0b41 (patch)
tree0e58a578a7113569b9f0464bd094e9164903c560 /internal/storage
parentdocs: Add TOFU certificate tracking to future ideas (diff)
downloadkaze-2f2549d6df7300b04a4550dc060a3d7f684a0b41.tar.xz
kaze-2f2549d6df7300b04a4550dc060a3d7f684a0b41.zip
feat: Add reset_on_next_check flag to wipe monitor history
Diffstat (limited to 'internal/storage')
-rw-r--r--internal/storage/sqlite.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/storage/sqlite.go b/internal/storage/sqlite.go
index e08e4ee..48cf432 100644
--- a/internal/storage/sqlite.go
+++ b/internal/storage/sqlite.go
@@ -673,6 +673,27 @@ func (s *Storage) Cleanup(ctx context.Context) error {
return nil
}
+// ResetMonitorData deletes all historical data for a specific monitor
+func (s *Storage) ResetMonitorData(ctx context.Context, monitorName string) error {
+ // Delete from check_results
+ _, err := s.db.ExecContext(ctx, `
+ DELETE FROM check_results WHERE monitor_name = ?
+ `, monitorName)
+ if err != nil {
+ return fmt.Errorf("failed to delete check_results for monitor %q: %w", monitorName, err)
+ }
+
+ // Delete from daily_stats
+ _, err = s.db.ExecContext(ctx, `
+ DELETE FROM daily_stats WHERE monitor_name = ?
+ `, monitorName)
+ if err != nil {
+ return fmt.Errorf("failed to delete daily_stats for monitor %q: %w", monitorName, err)
+ }
+
+ return nil
+}
+
// Close closes the database connection
func (s *Storage) Close() error {
return s.db.Close()