fix: allow closing draft CLs and fix draft list ordering#1982
Conversation
- Allow /api/v1/cl/{link}/close to close both Open and Draft change lists so draft CLs can be closed from the UI
- Remove default ORDER BY id ASC in CL list query and respect created_at/updated_at sorting
- Ensure newly created draft CLs appear on the first page when sorted by latest creation time
Signed-off-by: Hongze Gao <15101764808@163.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87d979a024
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if params.sort_by.is_none() { | ||
| sorted_query = sorted_query.order_by_desc(mega_cl::Column::Id); |
There was a problem hiding this comment.
Preserve default ordering when sort field is unrecognized
In get_cl_list, the fallback sort now runs only when sort_by is None, but the request model still accepts any sort_by string (ceres/src/model/change_list.rs), and apply_sort silently ignores unknown keys. If a client sends an unexpected value (e.g. typo or older field name), this path skips both dynamic sort and fallback, producing an unordered paginated query; that can cause unstable page results (items shifting/duplicating across pages). Before this change, the base ORDER BY id ASC at least kept pagination deterministic for invalid sort inputs.
Useful? React with 👍 / 👎.
- Ensure CL list falls back to ORDER BY id DESC when no valid sort field is provided - Treat unknown sort_by values the same as missing ones to keep pagination stable - Preserve created_at/updated_at based ordering when a recognized sort field is passed Signed-off-by: Hongze Gao <15101764808@163.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Signed-off-by: Hongze Gao <15101764808@163.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Summary
Changes
close_clhandler to close CLs when their status is eitherOpenorDraft, and still record aClosedconversation event.ORDER BY id ASCfromClStorage::get_cl_listto avoid overriding user-specified sort options.sort_by(created_atorupdated_at) andasc, and defaulted toORDER BY id DESCwhen no sort field is provided so newest CLs show up on the first page.Notes