fix(archive): מיון תיקי-ארכיב לפי תאריך-ארכוב (server-authoritative)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 7s
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 7s
דף /archive הציג תיקים בסדר updated_at במקום לפי תאריך-הארכוב, למרות שעמודת "תאריך ארכוב" סומנה כממוינת. השורש: list_cases() החזיר תמיד ORDER BY updated_at DESC, וההסתמכות על מיון-בדפדפן (TanStack) לא הבטיחה את הסדר בטעינה הראשונית. התיקון: כש-archived_only=True → ORDER BY archived_at DESC NULLS LAST. הסדר הופך server-authoritative; לא נוגע ברשימה הפעילה ולא ב-MCP tool (שאינו מעביר archived_only). Invariants: G1 (נרמול-במקור — סדר נקבע בשאילתה, לא תיקון-בקריאה), G2 (לא מסלול-מקביל — אותו list_cases), INV-IA* (מקור-אמת יחיד לרשימה). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1713,7 +1713,12 @@ async def list_cases(
|
||||
where.append("archived_at IS NULL")
|
||||
where_clause = f"WHERE {' AND '.join(where)}" if where else ""
|
||||
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:
|
||||
rows = await conn.fetch(sql, *args)
|
||||
return [_row_to_case(r) for r in rows]
|
||||
|
||||
Reference in New Issue
Block a user