-- TRAIL DPS 4.2.4 - Validation apres depot FTP
-- Base : synoluidpstrack
-- Onglet : SQL dans phpMyAdmin
-- Ce script ne modifie aucune donnee.

SELECT 'tracking_positions_latest rows' AS check_name, COUNT(*) AS row_count
FROM tracking_positions_latest;

SELECT 'tracking_positions_trace rows' AS check_name, COUNT(*) AS row_count
FROM tracking_positions_trace;

SELECT 'runner_location_requests rows' AS check_name, COUNT(*) AS row_count
FROM runner_location_requests;

SELECT 'latest updated_at max' AS check_name, MAX(updated_at) AS max_value
FROM tracking_positions_latest;

SELECT 'trace recorded_at_server max' AS check_name, MAX(recorded_at_server) AS max_value
FROM tracking_positions_trace;

SELECT 'raw purge candidates > 8h' AS check_name, COUNT(*) AS row_count
FROM tracking_positions
WHERE recorded_at_server < DATE_SUB(UTC_TIMESTAMP(), INTERVAL 8 HOUR);

SELECT 'trace purge candidates > 7d' AS check_name, COUNT(*) AS row_count
FROM tracking_positions_trace
WHERE recorded_at_server < DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY);

SELECT 'api log purge candidates > 30d' AS check_name, COUNT(*) AS row_count
FROM tracking_api_logs
WHERE created_at < DATE_SUB(UTC_TIMESTAMP(), INTERVAL 30 DAY);

SELECT 'error log purge candidates > 30d' AS check_name, COUNT(*) AS row_count
FROM tracking_error_logs
WHERE created_at < DATE_SUB(UTC_TIMESTAMP(), INTERVAL 30 DAY);
