feat: add PDF reports, timezone management, GPS QR codes, and fix GPS tracking gaps
Issue #1: QR button on GPS Devices tab for re-enrollment Issue #2: App-wide timezone setting with TimezoneContext, useFormattedDate hook, and admin timezone selector. All date displays now respect the configured timezone. Issue #3: PDF export for Accountability Roster using @react-pdf/renderer with professional styling matching VIPSchedulePDF. Added Signal send button. Issue #4: Fixed GPS "teleporting" gaps - syncPositions now fetches position history per device instead of only latest position. Changed cron to every 30s, added unique constraint on deviceId+timestamp for deduplication, lowered min interval to 10s. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
-- Delete duplicate rows keeping the first entry (by id) for each deviceId+timestamp pair
|
||||
DELETE FROM "gps_location_history" a
|
||||
USING "gps_location_history" b
|
||||
WHERE a."id" > b."id"
|
||||
AND a."deviceId" = b."deviceId"
|
||||
AND a."timestamp" = b."timestamp";
|
||||
|
||||
-- Drop the existing index that covered deviceId+timestamp (non-unique)
|
||||
DROP INDEX IF EXISTS "gps_location_history_deviceId_timestamp_idx";
|
||||
|
||||
-- CreateIndex (unique constraint replaces the old non-unique index)
|
||||
CREATE UNIQUE INDEX "gps_location_history_deviceId_timestamp_key" ON "gps_location_history"("deviceId", "timestamp");
|
||||
@@ -430,7 +430,7 @@ model GpsLocationHistory {
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@map("gps_location_history")
|
||||
@@index([deviceId, timestamp])
|
||||
@@unique([deviceId, timestamp]) // Prevent duplicate position records
|
||||
@@index([timestamp]) // For cleanup job
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user