fixed rolodex page
This commit is contained in:
10
app/main.py
10
app/main.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user