tracksolid_timescale_grafan.../db_audit/checks/duplicate_positions.sql
David Kiania 20d3ddb841 feat: add db_audit health checks, runner, and scheduled Forgejo workflow
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 21:40:29 +03:00

11 lines
348 B
SQL

-- Duplicate (imei, gps_time) pairs in position_history
-- Should always return 0 rows if ON CONFLICT DO NOTHING is working correctly
SELECT
imei,
gps_time,
COUNT(*) AS duplicate_count
FROM tracksolid.position_history
WHERE gps_time > NOW() - INTERVAL '7 days'
GROUP BY imei, gps_time
HAVING COUNT(*) > 1
ORDER BY duplicate_count DESC;