feat: add is_disney flag to asset sync - sets is_disney=1 for D- customers
INSERT and UPDATE now set is_disney based on whether the customer name starts with 'D-'. Admin DB also backfilled with the same logic.
This commit is contained in:
+7
-2
@@ -700,6 +700,10 @@ def approve_batch(batch_id: int, request: Request):
|
||||
if loc_id:
|
||||
updates["location_id"] = loc_id
|
||||
|
||||
# Set Disney flag based on customer name
|
||||
if cust_name:
|
||||
updates["is_disney"] = 1 if cust_name.startswith("D-") else 0
|
||||
|
||||
if updates:
|
||||
updates["updated_at"] = "datetime('now')"
|
||||
set_clause = ", ".join(
|
||||
@@ -731,9 +735,9 @@ def approve_batch(batch_id: int, request: Request):
|
||||
make, model, address, building_name, building_number,
|
||||
floor, room, trailer_number, walking_directions, map_link,
|
||||
parking_location, photo_path,
|
||||
customer_id, location_id,
|
||||
customer_id, location_id, is_disney,
|
||||
latitude, longitude, geofence_radius_meters)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(
|
||||
machine_id,
|
||||
str(item.get("serial_number", "")).strip() or "",
|
||||
@@ -755,6 +759,7 @@ def approve_batch(batch_id: int, request: Request):
|
||||
str(item.get("photo_path", "")).strip() or "",
|
||||
cust_id,
|
||||
loc_id,
|
||||
1 if cust_name and cust_name.startswith("D-") else 0,
|
||||
_safe_float(item.get("latitude")),
|
||||
_safe_float(item.get("longitude")),
|
||||
_safe_int(item.get("geofence_radius_meters"), 50),
|
||||
|
||||
Reference in New Issue
Block a user