From fc0a3ee9be43cb20588eeb63a8ca3d4ad6de64a7 Mon Sep 17 00:00:00 2001 From: Shawn Date: Wed, 20 May 2026 15:43:43 -0400 Subject: [PATCH] fix: auto-update asset lat/lng on check-in so map shows pins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously assets never had coordinates populated - only checkins did. Now when a checkin is created with GPS data, the asset's latitude/longitude fields are auto-updated. Also backfilled existing assets from their latest checkin history. This fixes empty maps — loadAssetPins() filters by a.latitude != null. --- server.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server.py b/server.py index baeb45e..3199f6a 100644 --- a/server.py +++ b/server.py @@ -1106,6 +1106,14 @@ def create_checkin(body: CheckinCreate): conn.commit() checkin_id = cursor.lastrowid + # Auto-update asset's last known location + if body.latitude is not None and body.longitude is not None: + conn.execute( + "UPDATE assets SET latitude = ?, longitude = ? WHERE id = ?", + (body.latitude, body.longitude, body.asset_id), + ) + conn.commit() + # Auto-log visit row = conn.execute("SELECT created_at FROM checkins WHERE id = ?", (checkin_id,)).fetchone() _auto_log_visit(conn, body.user_id, body.asset_id, row["created_at"])