forked from janek/mostr
1
0
Fork 0

feat: implement priority filtering

This commit is contained in:
xeruf 2024-11-09 20:41:22 +01:00
parent 91b6047f9a
commit 561fd9e1e5
2 changed files with 10 additions and 1 deletions

View File

@ -194,7 +194,7 @@ impl Task {
"created" => Some(format_timestamp_local(&self.event.created_at)), "created" => Some(format_timestamp_local(&self.event.created_at)),
"kind" => Some(self.event.kind.to_string()), "kind" => Some(self.event.kind.to_string()),
// Dynamic // Dynamic
"priority" | "prio" => self.priority_raw().map(|c| c.to_string()), "priority" => self.priority_raw().map(|c| c.to_string()),
"status" => self.state_label().map(|c| c.to_string()), "status" => self.state_label().map(|c| c.to_string()),
"desc" => self.descriptions().last().cloned(), "desc" => self.descriptions().last().cloned(),
"description" => Some(self.descriptions().join(" ")), "description" => Some(self.descriptions().join(" ")),

View File

@ -446,6 +446,9 @@ impl TasksRelay {
fn filter(&self, task: &Task) -> bool { fn filter(&self, task: &Task) -> bool {
self.state.matches(task) && self.state.matches(task) &&
self.priority.is_none_or(|prio| {
task.priority().unwrap_or(DEFAULT_PRIO) >= prio
}) &&
task.tags.as_ref().map_or(true, |tags| { task.tags.as_ref().map_or(true, |tags| {
!tags.iter().any(|tag| self.tags_excluded.contains(tag)) !tags.iter().any(|tag| self.tags_excluded.contains(tag))
}) && }) &&
@ -540,6 +543,12 @@ impl TasksRelay {
"progress" => prog_string.clone(), "progress" => prog_string.clone(),
"author" | "creator" => format!("{:.6}", self.get_username(&task.event.pubkey)), // FIXME temporary until proper column alignment "author" | "creator" => format!("{:.6}", self.get_username(&task.event.pubkey)), // FIXME temporary until proper column alignment
"prio" => task.priority_raw().map(|p| p.to_string()).unwrap_or_else(||
if self.priority.is_some() {
DEFAULT_PRIO.to_string().dimmed().to_string()
} else {
"".to_string()
}),
"path" => self.get_task_path(Some(task.event.id)), "path" => self.get_task_path(Some(task.event.id)),
"rpath" => self.relative_path(task.event.id), "rpath" => self.relative_path(task.event.id),
// TODO format strings configurable // TODO format strings configurable