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,