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:
2026-07-22 20:55:28 -07:00
co-authored by Claude Opus 4.8
parent 594ee7cfca
commit 9bbc077129
3 changed files with 11 additions and 2 deletions
+3 -1
View File
@@ -41,7 +41,9 @@ export class CustomersService {
where,
skip: (page - 1) * pageSize,
take: pageSize,
orderBy: { name: "asc" },
// Nameless records last: ordering by name alone floats every
// "(SIN NOMBRE)" to the top, since "(" sorts before every letter.
orderBy: [{ nameMissing: "asc" }, { name: "asc" }],
select: {
id: true,
name: true,