-- TRAIL DPS 4.2.2 - Validation apres depot FTP
-- A executer dans phpMyAdmin OVH, base synoluidpstrack, onglet SQL.
-- Ces requetes ne modifient pas les donnees.

SELECT 'tracking_positions_latest exists' AS check_name, COUNT(*) AS table_count
FROM information_schema.tables
WHERE table_schema = DATABASE()
  AND table_name = 'tracking_positions_latest';

SELECT 'tracking_positions_trace exists' AS check_name, COUNT(*) AS table_count
FROM information_schema.tables
WHERE table_schema = DATABASE()
  AND table_name = 'tracking_positions_trace';

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

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

SELECT 'latest last updates' AS check_name,
       id,
       event_remote_id,
       place_instance_id,
       binding_id,
       actor_type,
       recorded_at_server,
       updated_at
FROM tracking_positions_latest
ORDER BY updated_at DESC
LIMIT 10;

SELECT 'trace last points' AS check_name,
       id,
       event_remote_id,
       place_instance_id,
       binding_id,
       actor_type,
       recorded_at_server,
       trace_bucket_at,
       insert_reason
FROM tracking_positions_trace
ORDER BY recorded_at_server DESC, id DESC
LIMIT 20;
