diff --git a/backend/internal/services/uptime_service.go b/backend/internal/services/uptime_service.go index 91422a86..8ecc6d4b 100644 --- a/backend/internal/services/uptime_service.go +++ b/backend/internal/services/uptime_service.go @@ -1292,14 +1292,5 @@ func (s *UptimeService) CleanupStaleFailureCounts() error { logger.Log().WithField("reset_count", result.RowsAffected).Info("Reset stale monitor failure counts") } - hostResult := s.DB.Exec(`UPDATE uptime_hosts SET failure_count = 0, status = 'pending' WHERE status = 'down'`) - if hostResult.Error != nil { - return fmt.Errorf("cleanup stale host failure counts: %w", hostResult.Error) - } - - if hostResult.RowsAffected > 0 { - logger.Log().WithField("reset_count", hostResult.RowsAffected).Info("Reset stale host failure counts") - } - return nil } diff --git a/backend/internal/services/uptime_service_pr1_test.go b/backend/internal/services/uptime_service_pr1_test.go index 7c6b425e..6de1104c 100644 --- a/backend/internal/services/uptime_service_pr1_test.go +++ b/backend/internal/services/uptime_service_pr1_test.go @@ -311,11 +311,11 @@ func TestCleanupStaleFailureCounts_SkipsLowFailureCount(t *testing.T) { assert.Equal(t, "down", m.Status) } -func TestCleanupStaleFailureCounts_ResetsStaleHosts(t *testing.T) { +func TestCleanupStaleFailureCounts_DoesNotResetDownHosts(t *testing.T) { db := setupPR1TestDB(t) svc := NewUptimeService(db, nil) - // Create a "stuck" host + // Create a host that is currently down. host := models.UptimeHost{ ID: uuid.New().String(), Host: "stuck-host.local", @@ -330,8 +330,8 @@ func TestCleanupStaleFailureCounts_ResetsStaleHosts(t *testing.T) { var h models.UptimeHost require.NoError(t, db.First(&h, "id = ?", host.ID).Error) - assert.Equal(t, 0, h.FailureCount) - assert.Equal(t, "pending", h.Status) + assert.Equal(t, 10, h.FailureCount, "cleanup must not reset host failure_count") + assert.Equal(t, "down", h.Status, "cleanup must not reset host status") } // setupPR1ConcurrentDB creates a file-based SQLite database with WAL mode and