From f3c8ecc9e651798a7d4ae30404092aa0a72dfd23 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sat, 28 Oct 2023 15:06:58 -0700 Subject: [PATCH] Update deep clean code to actually execute the delete now that I validated that it is reasonable --- backend/server/internal/database/db.go | 2 +- backend/server/internal/server/srv.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/server/internal/database/db.go b/backend/server/internal/database/db.go index d618395..9b8f200 100644 --- a/backend/server/internal/database/db.go +++ b/backend/server/internal/database/db.go @@ -399,7 +399,7 @@ func (db *DB) DeepClean(ctx context.Context) error { return r.Error } r = tx.Exec(` - SELECT COUNT(*) FROM enc_history_entries WHERE + DELETE FROM enc_history_entries WHERE date <= (now() - INTERVAL '180 days') AND user_id IN (SELECT * FROM temp_users_with_one_device) AND user_id IN (SELECT * FROM temp_inactive_users) diff --git a/backend/server/internal/server/srv.go b/backend/server/internal/server/srv.go index e24d49a..723c2d7 100644 --- a/backend/server/internal/server/srv.go +++ b/backend/server/internal/server/srv.go @@ -90,7 +90,7 @@ func (s *Server) Run(ctx context.Context, addr string) error { defer configureObservability(mux, s.releaseVersion)() go func() { if err := s.db.DeepClean(ctx); err != nil { - panic(err) + fmt.Println("failed to deep clean: %w", err) } }() }