Merge pull request 'fix(archive): מיון תיקי-ארכיב לפי תאריך-ארכוב (server-authoritative)' (#217) from worktree-archive-sort-fix into main
This commit was merged in pull request #217.
This commit is contained in:
@@ -1713,7 +1713,12 @@ async def list_cases(
|
|||||||
where.append("archived_at IS NULL")
|
where.append("archived_at IS NULL")
|
||||||
where_clause = f"WHERE {' AND '.join(where)}" if where else ""
|
where_clause = f"WHERE {' AND '.join(where)}" if where else ""
|
||||||
args.append(limit)
|
args.append(limit)
|
||||||
sql = f"SELECT * FROM cases {where_clause} ORDER BY updated_at DESC LIMIT ${len(args)}"
|
# Archived list is ordered by archive date (newest-first) so the order is
|
||||||
|
# server-authoritative and the /archive page is correct on load, regardless
|
||||||
|
# of client-side sorting. NULLS LAST is defensive — the archived_only filter
|
||||||
|
# already excludes NULLs.
|
||||||
|
order_by = "archived_at DESC NULLS LAST" if archived_only else "updated_at DESC"
|
||||||
|
sql = f"SELECT * FROM cases {where_clause} ORDER BY {order_by} LIMIT ${len(args)}"
|
||||||
async with pool.acquire() as conn:
|
async with pool.acquire() as conn:
|
||||||
rows = await conn.fetch(sql, *args)
|
rows = await conn.fetch(sql, *args)
|
||||||
return [_row_to_case(r) for r in rows]
|
return [_row_to_case(r) for r in rows]
|
||||||
|
|||||||
Reference in New Issue
Block a user