feat: summarize time tracked on visible tasks

This commit is contained in:
xeruf 2024-08-08 15:14:04 +03:00
parent 43c62bf742
commit b62ec6fd39
1 changed files with 9 additions and 1 deletions

View File

@ -353,6 +353,7 @@ impl Tasks {
} }
// TODO proper column alignment // TODO proper column alignment
writeln!(lock, "{}", self.properties.join("\t").bold())?; writeln!(lock, "{}", self.properties.join("\t").bold())?;
let mut total_time = 0;
for task in self.current_tasks() { for task in self.current_tasks() {
writeln!( writeln!(
lock, lock,
@ -383,13 +384,20 @@ impl Tasks {
"rpath" => self.relative_path(task.event.id), "rpath" => self.relative_path(task.event.id),
// TODO format strings as config // TODO format strings as config
"time" => display_time("MMMm", self.time_tracked(*task.get_id())), "time" => display_time("MMMm", self.time_tracked(*task.get_id())),
"rtime" => display_time("HH:MM", self.total_time_tracked(*task.get_id())), "rtime" => {
let time = self.total_time_tracked(*task.get_id());
total_time += time;
display_time("HH:MM", time)
},
prop => task.get(prop).unwrap_or(String::new()), prop => task.get(prop).unwrap_or(String::new()),
}) })
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(" \t") .join(" \t")
)?; )?;
} }
if total_time > 0 {
writeln!(lock, "{}", display_time("Total time tracked on visible tasks: HHh MMm", total_time))?;
}
Ok(()) Ok(())
} }