tracked time total
This commit is contained in:
		
							
								
								
									
										10
									
								
								src/stats.rs
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/stats.rs
									
									
									
									
									
								
							@@ -72,6 +72,7 @@ pub fn time_per_tag(days : u16, vault_folder : &path::Path) -> Result<(), error:
 | 
			
		||||
    table.set_header(vec!["Tag", "Time"]);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    let mut total_duration = tasks::Duration::zero();
 | 
			
		||||
    for (tag, duration) in times {
 | 
			
		||||
        table.add_row(
 | 
			
		||||
            vec![
 | 
			
		||||
@@ -79,8 +80,17 @@ pub fn time_per_tag(days : u16, vault_folder : &path::Path) -> Result<(), error:
 | 
			
		||||
                duration.to_string(),
 | 
			
		||||
            ]
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        total_duration = total_duration + duration;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    table.add_row(
 | 
			
		||||
        vec![
 | 
			
		||||
            String::from("Total"),
 | 
			
		||||
            total_duration.to_string(),
 | 
			
		||||
        ]
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    println!("{}", table);
 | 
			
		||||
 | 
			
		||||
    Ok(())
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								src/tasks.rs
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/tasks.rs
									
									
									
									
									
								
							@@ -273,9 +273,16 @@ impl Task {
 | 
			
		||||
            // Sort entries by date.
 | 
			
		||||
            entries.sort_by(|e1, e2| e1.logged_date.cmp(&e2.logged_date));
 | 
			
		||||
 | 
			
		||||
            println!("Time Entries:");
 | 
			
		||||
            let mut total = Duration::zero();
 | 
			
		||||
            let mut lines = Vec::with_capacity(entries.len());
 | 
			
		||||
            for entry in &entries {
 | 
			
		||||
                println!("    {} [{}]", entry.duration, entry.logged_date);
 | 
			
		||||
                lines.push(format!("    {} [{}]", entry.duration, entry.logged_date));
 | 
			
		||||
                total = total + entry.duration;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            println!("Time Entries (totaling {}):", total);
 | 
			
		||||
            for line in lines {
 | 
			
		||||
                println!("{}", line);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user