mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
a62ead8588
The GetChats SQL query ordered by (updated_at, id) DESC with no pin_order awareness. A pinned chat with an old updated_at could land on page 2+ and be invisible in the sidebar's Pinned section. Add a 4-column ORDER BY: pinned-first flag DESC, negated pin_order DESC, updated_at DESC, id DESC. The negation trick keeps all sort columns DESC so the cursor tuple < comparison still works. Update the after_id cursor clause to match the expanded sort key. Fix the false handler comment claiming PinChatByID bumps updated_at.
6 lines
343 B
SQL
6 lines
343 B
SQL
-- The GetChats ORDER BY changed from (updated_at, id) DESC to a 4-column
|
|
-- expression sort (pinned-first flag, negated pin_order, updated_at, id).
|
|
-- This index was purpose-built for the old sort and no longer provides
|
|
-- read benefit. The simpler idx_chats_owner covers the owner_id filter.
|
|
DROP INDEX IF EXISTS idx_chats_owner_updated_id;
|