(1845355) Order each status column by its entry stamp, and bump to 0.23.0
Every view read its rows out of `collect_ticket_items`, which sorts by `by_priority_then_title` because it sees one directory and no status. That is the right order for the backlog, where priority is the clock. Past the backlog the question changes: committed asks what has waited longest, reviewing what was handed over first, done what just landed. All four columns answering the first question is why a finished p5 sat above the p1 nobody had read yet. So each column takes its own order, through one `by_status_order` keyed on the `Status` rather than four comparators at four call sites. Backlog delegates to the comparator it already used. Committed sorts by `Committed On` ascending and reviewing by `Submitted On` ascending, so the longest wait is at the head where the reader picks next from; done sorts by `Completed On` descending, newest first, the way a changelog reads. Ascending twice and once descending is one rule said three ways: the head of every column is what the reader acts on next. A ticket carrying no stamp sinks below every stamped one in its column and falls back to priority then title among its own kind, as do equal stamps -- `mv` writes whole seconds, so a tie is real. A missing time is unknown, not ancient, and unknown must not claim the head of a queue ahead of a wait somebody can point at. Reading absence as the epoch would have come free from the comparison and put every ticket filed before f460853 first. The comparison is a string comparison. `%Y-%m-%d %H:%M:%S` is lexicographic in chronological order, the property `Due` already relies on, so nothing parses a date at sort time. The stamps are read on the pass `collect_ticket_items` already makes over each file, the rule `criteria` and `tags` already hold, and never per comparison. Both `cmd_ls` branches, `list_ids`, `columns_of` and `campaign::members` take it, which is why those loops walk `Status::ALL` rather than `status_dirs()`: the directory name does not say which stamp governs it. The merge tab keeps priority then title outright and is pinned there -- it spans statuses, so no single stamp governs it. `cmd_tags` is left alone; it counts into a `BTreeMap` and never reads an order. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
eae411ab50
commit
cbc20848f6
+27
-16
@@ -63,8 +63,10 @@ pub fn cmd_ls(args: &LsArgs, worklane_dir: &Path) -> Result<()> {
|
||||
}
|
||||
|
||||
if let Some(status) = args.status {
|
||||
let status = status.as_str();
|
||||
let status_path = worklane_dir.join(status);
|
||||
// The `Status` is kept alongside its name: the directory is joined from the
|
||||
// name, and the order the column prints in is keyed on the status itself.
|
||||
let name = status.as_str();
|
||||
let status_path = worklane_dir.join(name);
|
||||
if !status_path.exists() {
|
||||
// The status itself is clap's to reject now, so reaching here means the
|
||||
// board is missing a directory it should have rather than that the name was
|
||||
@@ -72,19 +74,20 @@ pub fn cmd_ls(args: &LsArgs, worklane_dir: &Path) -> Result<()> {
|
||||
// alone.
|
||||
return Err(anyhow!(
|
||||
"No '{}' directory in {}. Every board has all four; creating it is enough.",
|
||||
status,
|
||||
name,
|
||||
worklane_dir.display()
|
||||
));
|
||||
}
|
||||
|
||||
let items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid, tag);
|
||||
let mut items = filtered(collect_ticket_items(&status_path)?, priority_filter, uuid, tag);
|
||||
items.sort_by(|a, b| by_status_order(status, a, b));
|
||||
|
||||
if items.is_empty() {
|
||||
println!("No tickets in '{}' status.", status);
|
||||
println!("No tickets in '{}' status.", name);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
println!("Tickets in '{}' status:\n", status);
|
||||
println!("Tickets in '{}' status:\n", name);
|
||||
display_ticket_items(&items);
|
||||
} else {
|
||||
// List all statuses with their ticket counts
|
||||
@@ -101,23 +104,27 @@ pub fn cmd_ls(args: &LsArgs, worklane_dir: &Path) -> Result<()> {
|
||||
println!(" [{}] {} {}", status.to_uppercase(), count, label);
|
||||
}
|
||||
|
||||
// Show all tickets except done grouped by status
|
||||
for status in &statuses {
|
||||
if *status == DONE {
|
||||
// Show all tickets except done grouped by status. Over `Status::ALL` rather
|
||||
// than the names, because each column is ordered by its own entry stamp and the
|
||||
// comparator is keyed on the status, not on the directory it was read from.
|
||||
for status in Status::ALL {
|
||||
if status.as_str() == DONE {
|
||||
continue;
|
||||
}
|
||||
let status_path = worklane_dir.join(status);
|
||||
let status_path = worklane_dir.join(status.as_str());
|
||||
if !status_path.exists() || !fs::metadata(&status_path)?.is_dir() {
|
||||
continue;
|
||||
}
|
||||
let items = match collect_ticket_items(&status_path) {
|
||||
let mut items = match collect_ticket_items(&status_path) {
|
||||
Ok(items) => filtered(items, priority_filter, uuid, tag),
|
||||
Err(_) => continue,
|
||||
};
|
||||
items.sort_by(|a, b| by_status_order(status, a, b));
|
||||
if items.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let status_header = color_text(&format!("[{}]", status.to_uppercase()), Color::Orange);
|
||||
let status_header =
|
||||
color_text(&format!("[{}]", status.as_str().to_uppercase()), Color::Orange);
|
||||
println!("\n{}", status_header);
|
||||
display_ticket_items(&items);
|
||||
}
|
||||
@@ -150,16 +157,20 @@ fn list_ids(
|
||||
worklane_dir: &Path,
|
||||
) -> Result<()> {
|
||||
let statuses = match status {
|
||||
Some(status) => vec![status.as_str()],
|
||||
None => status_dirs(),
|
||||
Some(status) => vec![status],
|
||||
None => Status::ALL.to_vec(),
|
||||
};
|
||||
|
||||
for status in statuses {
|
||||
let status_path = worklane_dir.join(status);
|
||||
let status_path = worklane_dir.join(status.as_str());
|
||||
if !status_path.exists() {
|
||||
continue;
|
||||
}
|
||||
for item in filtered(collect_ticket_items(&status_path)?, level, campaign, tag) {
|
||||
// The same order the listing prints, so a completion and the board agree on
|
||||
// which ticket is at the head of a column.
|
||||
let mut items = filtered(collect_ticket_items(&status_path)?, level, campaign, tag);
|
||||
items.sort_by(|a, b| by_status_order(status, a, b));
|
||||
for item in items {
|
||||
println!("{}\t{}", item.id, item.title);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user