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:
co-authored by
Claude Opus 5
parent
cd7c99fe39
commit
c81838efc6
+81
-2
@@ -114,14 +114,16 @@ fn ls_with_invalid_status_fails() {
|
||||
.failure();
|
||||
}
|
||||
|
||||
/// Title is the last tiebreak, so the three share a due date and a priority: anything
|
||||
/// else here would be testing the due order instead, which has its own case.
|
||||
#[test]
|
||||
fn ls_listed_tickets_sorted_alphabetically() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
create_ticket(&worklane, "backlog", "Zebra", "alice", "2026-06-01");
|
||||
create_ticket(&worklane, "backlog", "Apple", "bob", "2026-07-01");
|
||||
create_ticket(&worklane, "backlog", "Mango", "charlie", "2026-08-01");
|
||||
create_ticket(&worklane, "backlog", "Apple", "bob", "2026-06-01");
|
||||
create_ticket(&worklane, "backlog", "Mango", "charlie", "2026-06-01");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path())
|
||||
@@ -744,6 +746,32 @@ fn create_stamped_ticket(
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// A backlog ticket with the due date that column is ordered by.
|
||||
///
|
||||
/// Backlog only, the way [`create_stamped_ticket`] is one status at a time: the due is
|
||||
/// what stands in for an entry stamp in the one column that has none, and `_Not set_`
|
||||
/// passed here is the undated case rather than a separate helper.
|
||||
fn create_due_ticket(
|
||||
worklane_dir: &std::path::Path,
|
||||
title: &str,
|
||||
uuid: &str,
|
||||
priority: &str,
|
||||
due: &str,
|
||||
) {
|
||||
let body = format!(
|
||||
"# {title}\n\n## Metadata\n\n- **ID**: {uuid}\n- **Priority**: {priority}\n\
|
||||
- **Tags**: test\n- **Due**: {due}\n- **Owner**: alice\n\
|
||||
- **Status**: backlog\n"
|
||||
);
|
||||
fs::write(
|
||||
worklane_dir
|
||||
.join("backlog")
|
||||
.join(format!("{uuid}_{}.md", slug(title))),
|
||||
body,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn positions(stdout: &str, titles: [&str; 3]) -> Vec<usize> {
|
||||
titles
|
||||
.iter()
|
||||
@@ -828,6 +856,57 @@ fn ls_orders_done_by_the_newest_entry_stamp() {
|
||||
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
|
||||
}
|
||||
|
||||
/// The backlog has no entry stamp, so the due date is its clock and the soonest deadline
|
||||
/// heads the column. The p1 here is due last and is listed last, which is exactly what
|
||||
/// priority alone got wrong.
|
||||
#[test]
|
||||
fn ls_orders_the_backlog_by_the_soonest_due_date() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let at = |n: u8| format!("dddd000{n}-0000-0000-0000-000000000001");
|
||||
create_due_ticket(&worklane, "Soonest", &at(1), "5", "2026-09-01");
|
||||
create_due_ticket(&worklane, "Latest", &at(2), "1", "2026-09-03");
|
||||
create_due_ticket(&worklane, "Between", &at(3), "3", "2026-09-02");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "backlog"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
|
||||
let seen = positions(&stdout, ["Soonest", "Between", "Latest"]);
|
||||
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
|
||||
|
||||
// The overview lists the same column, so it has to agree with the narrowed listing
|
||||
// rather than falling back to priority for the same tickets.
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).arg("ls");
|
||||
let overview = get_stdout(&mut cmd);
|
||||
|
||||
let seen = positions(&overview, ["Soonest", "Between", "Latest"]);
|
||||
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{overview}");
|
||||
}
|
||||
|
||||
/// A due nobody promised must not outrank one somebody did. The undated ticket here is
|
||||
/// the most urgent of the three and still trails both, and among the dated ones the
|
||||
/// equal due falls through to priority.
|
||||
#[test]
|
||||
fn ls_sinks_an_undated_backlog_ticket_below_the_dated_ones() {
|
||||
let temp = TempDir::new().unwrap();
|
||||
let worklane = setup_worklane(&temp);
|
||||
|
||||
let at = |n: u8| format!("eeee000{n}-0000-0000-0000-000000000001");
|
||||
create_due_ticket(&worklane, "Undated", &at(1), "1", "_Not set_");
|
||||
create_due_ticket(&worklane, "Urgent", &at(2), "3", "2026-09-01");
|
||||
create_due_ticket(&worklane, "Relaxed", &at(3), "5", "2026-09-01");
|
||||
|
||||
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||
cmd.current_dir(temp.path()).args(["ls", "backlog"]);
|
||||
let stdout = get_stdout(&mut cmd);
|
||||
|
||||
let seen = positions(&stdout, ["Urgent", "Relaxed", "Undated"]);
|
||||
assert!(seen[0] < seen[1] && seen[1] < seen[2], "{stdout}");
|
||||
}
|
||||
|
||||
/// A missing stamp is unknown, not ancient, so it sinks below every stamped ticket
|
||||
/// rather than claiming the head of the queue. Every ticket on a board older than the
|
||||
/// stamps is one of these.
|
||||
|
||||
Reference in New Issue
Block a user