Sort the backlog by due date, then priority

The backlog was the one column priority governed alone, which sat a p1
nobody had promised above a p3 due tomorrow. It has no entry stamp, so it
now takes the due date as the date `by_status_order` keys on: soonest
first, undated below every dated one, and priority then title as the
tiebreak, which is still the whole order among the undated ones.

`TicketItem::due_key` is where a due becomes an orderable date. Only a
plain `YYYY-MM-DD` counts, which is all `--due` has accepted since
daa0e79, with `due_date` cutting a legacy datetime back to its date.
Free text answers `None` and sinks with the unset ones rather than
sorting on its spelling: a due nobody can place on a calendar is
unknown, the same reading a missing stamp already gets.

The comparator stays the single function keyed on `Status`, so `ls`,
`ls --ids`, the board's columns and `campaign::members` move together.
The All tab keeps `by_priority_then_title`: that merge spans statuses,
so no single date governs it.

`ls_listed_tickets_sorted_alphabetically` gave its three tickets three
different due dates while asserting title order. They share one now, so
the case still tests the tiebreak it names rather than the new order.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-09-01 01:10:41 +02:00
co-authored by Claude Opus 5
parent cd7c99fe39
commit c81838efc6
5 changed files with 255 additions and 33 deletions
+26 -3
View File
@@ -9175,9 +9175,9 @@ approach";
.collect()
}
/// Each column is ordered by its own entry stamp, not by priority: committed is the
/// longest wait first, done is what just landed first. Every ticket here is a p2, so
/// the stamp is doing all of the work.
/// Every column past the backlog is ordered by its own entry stamp, not by priority:
/// committed is the longest wait first, done is what just landed first. Every ticket
/// here is a p2, so the stamp is doing all of the work.
#[test]
fn a_column_is_ordered_by_the_stamp_the_ticket_entered_it_with() {
let dir = board_dir();
@@ -9218,6 +9218,29 @@ approach";
assert_eq!(column_titles(&board, 3), ["Newer", "Older"]);
}
/// The backlog is the column with no entry stamp, so the due date is what orders it.
/// Every ticket here is a p2, so the due is doing all of the work, and the undated
/// one trails both dated ones rather than sitting among them.
#[test]
fn the_backlog_column_is_ordered_by_the_due_date() {
let dir = board_dir();
let card = |uuid: &str, title: &str, due: &str| {
let path = write_ticket(&dir, "backlog", uuid, title, "");
let body = std::fs::read_to_string(&path)
.unwrap()
.replace("- **Due**: 2026-12-31", &format!("- **Due**: {due}"));
std::fs::write(&path, body).unwrap();
};
card("11111111-0000-4000-8000-000000000000", "Later", "2026-09-03");
card("22222222-0000-4000-8000-000000000000", "Undated", "_Not set_");
card("33333333-0000-4000-8000-000000000000", "Sooner", "2026-09-01");
let board = boards(&[("only", &dir)]);
assert_eq!(column_titles(&board, 0), ["Sooner", "Later", "Undated"]);
}
/// The merge spans statuses, so no single stamp governs it and it keeps priority then
/// title. Pinned on done, where the column order and the merge order disagree: the
/// board would put the newest first and the merge puts the p1 first.