fixed rolodex page

This commit is contained in:
HotSwapp
2025-10-07 23:09:15 -05:00
parent fdcff9fbb2
commit 2efbf14940
8 changed files with 104189 additions and 79 deletions

View File

@@ -2028,8 +2028,14 @@ async def rolodex_list(
# Use EXISTS over join to avoid duplicate rows
query = query.filter(Client.phones.any(Phone.phone_number.ilike(like_phone)))
# Order by last then first for stable display
query = query.order_by(Client.last_name.asc().nulls_last(), Client.first_name.asc().nulls_last())
# Order by last then first for stable display (SQLite-safe nulls last)
# SQLite does not support "NULLS LAST"; emulate by sorting non-nulls first, then value
query = query.order_by(
Client.last_name.is_(None),
Client.last_name.asc(),
Client.first_name.is_(None),
Client.first_name.asc(),
)
total: int = query.count()
total_pages: int = (total + page_size - 1) // page_size if total > 0 else 1