From 6fd9238f790b2c1328029334a8529cc115d37292 Mon Sep 17 00:00:00 2001 From: Shawn Date: Tue, 2 Jun 2026 22:56:04 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20GPS=20never=20from=20seed=20=E2=80=94=20?= =?UTF-8?q?only=20from=20real=20check-ins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GPS (latitude/longitude) and photo_path are now NEVER set by seed import pipelines, even if empty. GPS comes only from field tech check-ins via the main app. - db_writer.py: FIELDS_NEVER_FROM_SEED set, GPS always None in _extract_row_values, skipped in update mode - sync.py: latitude/longitude set to None in asset_data - FIELD_MAP.md: updated policy table --- db_writer.py | 11 ++++++++++- sync.py | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/db_writer.py b/db_writer.py index a84ea0e..0021c29 100644 --- a/db_writer.py +++ b/db_writer.py @@ -156,6 +156,10 @@ EXTRA_COLUMNS = ["created_at", "updated_at"] EXTERNAL_PRESERVE_FIELDS = {"latitude", "longitude", "photo_path"} +# Fields that are NEVER set from seed data — GPS comes only from real check-ins +FIELDS_NEVER_FROM_SEED = {"latitude", "longitude", "photo_path"} + + def _serialize_value(val): """Convert a Python value to a SQLite-friendly value.""" if val is None: @@ -291,7 +295,8 @@ class DatabaseWriter: elif col in ("yearly_sales", "monthly_sales", "weekly_sales"): row[col] = _serialize_value(machine.get(col)) elif col in ("latitude", "longitude"): - row[col] = _serialize_value(machine.get(col)) + # GPS comes only from real check-ins, never from seed + row[col] = None else: val = machine.get(col) if val is not None and not isinstance(val, (str, int, float, bool)): @@ -418,6 +423,10 @@ class DatabaseWriter: for col in update_cols: if col == "machine_id": continue # PK — never update + # GPS and photo come only from real check-ins, never from seed + if col in FIELDS_NEVER_FROM_SEED: + skipped_count += 1 + continue new_val = row.get(col) old_val = existing_dict.get(col) # Skip if existing value is non-null/empty (MSFS or user data wins) diff --git a/sync.py b/sync.py index f626d7c..2bc1461 100644 --- a/sync.py +++ b/sync.py @@ -200,8 +200,8 @@ def push(source_db: str, target_db: str, dry_run: bool = False) -> dict: "customer_id": customer_id, "location_id": location_id, "assigned_to": None, - "latitude": _val(r, "latitude"), - "longitude": _val(r, "longitude"), + "latitude": None, # GPS comes only from real check-ins + "longitude": None, # GPS comes only from real check-ins "geofence_radius_meters": 50, "disney_park": _val(r, "disney_park"), "is_disney": is_disney,