remove robots from db

This commit is contained in:
JurajKubrican
2025-09-08 13:02:00 +02:00
parent caaa314065
commit 03a9dcff22
3 changed files with 34 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
-- This migration is irreversible as we're deleting historical data
-- If needed, you would need to restore from a backup
-- No-op down migration since we can't restore deleted tracking events
SELECT 1;

View File

@@ -0,0 +1,29 @@
-- Remove tracking events that match current ignored patterns
-- Remove visits to ignored paths
DELETE FROM user_visits WHERE
path = '/tracking' OR
path = '/metrics' OR
path LIKE '/css/%' OR
path LIKE '/js/%' OR
path = '/boxes/ws' OR
path LIKE '%favicon%';
-- Remove visits from ignored user agents
DELETE FROM user_visits WHERE
user_agent LIKE '%Prometheus%' OR
user_agent LIKE '%UptimeRobot%' OR
user_agent LIKE 'NetworkingExtension%';
-- Optional: Clean up any other common bot/monitoring patterns that might exist
DELETE FROM user_visits WHERE
user_agent LIKE '%bot%' OR
user_agent LIKE '%Bot%' OR
user_agent LIKE '%crawler%' OR
user_agent LIKE '%Crawler%' OR
user_agent LIKE '%spider%' OR
user_agent LIKE '%Spider%' OR
user_agent LIKE '%monitor%' OR
user_agent LIKE '%Monitor%' OR
user_agent LIKE '%health%' OR
user_agent LIKE '%Health%';

View File

@@ -101,7 +101,6 @@ func main() {
})) }))
} }
// MY supper tracking
e.Use(tracking.EchoWithConfig(tracking.TrackingConfig{ e.Use(tracking.EchoWithConfig(tracking.TrackingConfig{
IgnorePaths: []string{"/tracking", "/metrics", "/css/*", "/js/*", "/boxes/ws", "*favicon*"}, IgnorePaths: []string{"/tracking", "/metrics", "/css/*", "/js/*", "/boxes/ws", "*favicon*"},
IgnoreUserAgents: []string{"*Prometheus*", "*UptimeRobot*", "NetworkingExtension*"}, IgnoreUserAgents: []string{"*Prometheus*", "*UptimeRobot*", "NetworkingExtension*"},