forked from janek/mostr
1
0
Fork 0

feat(tasks): improve visible tasks summary

This commit is contained in:
xeruf 2024-08-13 11:59:57 +03:00
parent c67ef3b119
commit 6d4666c12d
1 changed files with 6 additions and 4 deletions

View File

@ -402,6 +402,7 @@ impl Tasks {
writeln!(lock, "{}", self.properties.join("\t").bold())?; writeln!(lock, "{}", self.properties.join("\t").bold())?;
let mut total_time = 0; let mut total_time = 0;
let mut tasks = self.current_tasks(); let mut tasks = self.current_tasks();
let count = tasks.len();
tasks.sort_by_cached_key(|task| { tasks.sort_by_cached_key(|task| {
self.sorting self.sorting
.iter() .iter()
@ -412,15 +413,16 @@ impl Tasks {
writeln!( writeln!(
lock, lock,
"{}", "{}",
self.properties self.properties.iter()
.iter()
.map(|p| self.get_property(task, p.as_str())) .map(|p| self.get_property(task, p.as_str()))
.join(" \t") .join(" \t")
)?; )?;
total_time += self.total_time_tracked(task.event.id) if self.depth < 2 || task.parent_id() == self.position.as_ref() {
total_time += self.total_time_tracked(task.event.id)
}
} }
if total_time > 0 { if total_time > 0 {
writeln!(lock, "{}", display_time("Total time tracked on visible tasks: HHh MMm", total_time))?; writeln!(lock, "{} visible tasks{}", count, display_time(" tracked a total of HHhMMm", total_time))?;
} }
Ok(()) Ok(())
} }