make ent list sort issues first by state, then by ctime
This commit is contained in:
parent
a08b514c34
commit
9933b139d9
2 changed files with 33 additions and 2 deletions
|
|
@ -61,8 +61,39 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
|
||||||
Commands::List => {
|
Commands::List => {
|
||||||
let issues =
|
let issues =
|
||||||
entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?;
|
entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?;
|
||||||
|
|
||||||
|
let mut uuids_by_state = std::collections::HashMap::<
|
||||||
|
entomologist::issue::State,
|
||||||
|
Vec<&entomologist::issue::IssueHandle>,
|
||||||
|
>::new();
|
||||||
for (uuid, issue) in issues.issues.iter() {
|
for (uuid, issue) in issues.issues.iter() {
|
||||||
println!("{} {} ({:?})", uuid, issue.title(), issue.state);
|
uuids_by_state
|
||||||
|
.entry(issue.state.clone())
|
||||||
|
.or_default()
|
||||||
|
.push(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
use entomologist::issue::State;
|
||||||
|
for state in [
|
||||||
|
State::InProgress,
|
||||||
|
State::Blocked,
|
||||||
|
State::Backlog,
|
||||||
|
State::New,
|
||||||
|
State::Done,
|
||||||
|
State::WontDo,
|
||||||
|
] {
|
||||||
|
let these_uuids = uuids_by_state.entry(state.clone()).or_default();
|
||||||
|
these_uuids.sort_by(|a_id, b_id| {
|
||||||
|
let a = issues.issues.get(*a_id).unwrap();
|
||||||
|
let b = issues.issues.get(*b_id).unwrap();
|
||||||
|
a.timestamp.cmp(&b.timestamp)
|
||||||
|
});
|
||||||
|
println!("{:?}:", state);
|
||||||
|
for uuid in these_uuids {
|
||||||
|
let issue = issues.issues.get(*uuid).unwrap();
|
||||||
|
println!("{} {}", uuid, issue.title());
|
||||||
|
}
|
||||||
|
println!("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use std::str::FromStr;
|
||||||
#[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, serde::Deserialize)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq, serde::Deserialize)]
|
||||||
/// These are the states an issue can be in.
|
/// These are the states an issue can be in.
|
||||||
pub enum State {
|
pub enum State {
|
||||||
New,
|
New,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue