use metis_core::{domain::documents::types::Phase, Adr, Document, Initiative, Strategy, Task};
pub fn extract_adr_number(id: &str) -> u32 {
if let Some(dash_pos) = id.find('-') {
if let Ok(num) = id[..dash_pos].parse::<u32>() {
return num;
}
}
0
}
pub fn get_strategy_column_index(strategy: &Strategy) -> usize {
match strategy.phase() {
Ok(Phase::Shaping) => 0,
Ok(Phase::Design) => 1,
Ok(Phase::Ready) => 2,
Ok(Phase::Active) => 3,
Ok(Phase::Completed) => 4,
_ => 0, }
}
pub fn get_initiative_column_index(initiative: &Initiative) -> usize {
match initiative.phase() {
Ok(Phase::Discovery) => 0,
Ok(Phase::Design) => 1,
Ok(Phase::Ready) => 2,
Ok(Phase::Decompose) => 3,
Ok(Phase::Active) => 4,
Ok(Phase::Completed) => 5,
_ => 0, }
}
pub fn get_task_column_index(task: &Task) -> usize {
match task.phase() {
Ok(Phase::Todo) => 0,
Ok(Phase::Active) => 1,
Ok(Phase::Blocked) => 2,
Ok(Phase::Completed) => 3,
_ => 0, }
}
pub fn get_adr_column_index(adr: &Adr) -> usize {
match adr.phase() {
Ok(Phase::Draft) => 0,
Ok(Phase::Discussion) => 1,
Ok(Phase::Decided) => 2,
Ok(Phase::Superseded) => 3,
_ => 0, }
}
pub fn get_backlog_column_index(task: &Task) -> usize {
use metis_core::domain::documents::types::Tag;
for tag in &task.core().tags {
if let Tag::Label(label) = tag {
match label.as_str() {
"bug" => return 1, "feature" => return 2, "tech-debt" => return 3, _ => {}
}
}
}
0
}