Customers: sort nameless records last instead of first
The 44 customers with no recoverable name render as "(SIN NOMBRE)", and
ordering the list by name alone floated all of them to the top — "(" sorts
before every letter — so the first two screens of the customer browser were
nothing but placeholders. Small number, worst possible position.
Adds customers.nameMissing, set by the transform and used as the primary sort
key so those records land at the end of the list. Denormalized rather than
computed in the query because the list is paginated in SQL, so the ordering
has to be expressible as a column.
Applied to the dev DB as an ALTER + UPDATE in place (no truncate), so the
existing loaded data and its FKs were left alone.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -170,6 +170,7 @@ def customer_from_utilities(row, name_index) -> dict:
|
||||
id=str(uuid.uuid4()),
|
||||
name=name,
|
||||
nameSource=name_source,
|
||||
nameMissing=int(name == NO_NAME),
|
||||
addressLine1=s(row["direccion"]),
|
||||
addressLine2=s(row["colonia"]),
|
||||
city=s(row["ciudad"]),
|
||||
@@ -197,6 +198,7 @@ def customer_from_insurance(row, name_index) -> dict:
|
||||
id=str(uuid.uuid4()),
|
||||
name=name,
|
||||
nameSource=name_source,
|
||||
nameMissing=int(name == NO_NAME),
|
||||
addressLine1=s(row["direccion_1"]),
|
||||
addressLine2=s(row["direccion_2"]),
|
||||
city=s(row["ciudad"]),
|
||||
@@ -219,7 +221,7 @@ def customer_from_insurance(row, name_index) -> dict:
|
||||
|
||||
|
||||
_CUST_COLS = [
|
||||
"id", "name", "nameSource", "addressLine1", "addressLine2", "city", "state", "zipCode",
|
||||
"id", "name", "nameSource", "nameMissing", "addressLine1", "addressLine2", "city", "state", "zipCode",
|
||||
"country", "phone", "mobile", "fax", "email", "notes", "identificationType",
|
||||
"identificationNumber", "identificationExpiration", "customerSince",
|
||||
"status", "feeAmount", "updatedAt",
|
||||
@@ -276,6 +278,7 @@ def main() -> None:
|
||||
if master["name"] == NO_NAME and ins_rec["name"] != NO_NAME:
|
||||
master["name"] = ins_rec["name"]
|
||||
master["nameSource"] = ins_rec["nameSource"] or "DATGRAL (seguros)"
|
||||
master["nameMissing"] = 0
|
||||
from_ins_side += 1
|
||||
enrich.append((cust_id, ins_rec))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user