Files
iistwin/migrations/0072_gps_speed_kmh_trips.sql

10 lines
814 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Скорости из Traccar были сохранены в узлах — домножаем историю на 1.852
-- (только трекерные объекты с external_id; у PWA-персон уже км/ч).
UPDATE gps_positions p SET speed = ROUND((p.speed * 1.852)::numeric, 1)
FROM gps_assets a WHERE p.asset_id = a.id AND a.external_id IS NOT NULL AND p.speed IS NOT NULL;
UPDATE gps_assets SET last_speed = ROUND((last_speed * 1.852)::numeric, 1) WHERE external_id IS NOT NULL AND last_speed IS NOT NULL;
-- Настройка деления трека на поездки: стоянка дольше N минут = конец поездки
-- (0 = не делить на поездки).
ALTER TABLE gps_settings ADD COLUMN IF NOT EXISTS trip_stop_minutes INTEGER NOT NULL DEFAULT 10;