fix: GPS never from seed — only from real check-ins
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
This commit is contained in:
+10
-1
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user