Don't duplicate current session print
This commit is contained in:
parent
8b967001f4
commit
eeae39d050
|
@ -212,7 +212,7 @@ fn format_bar(seconds: i64, max_value: i64, width: usize) -> String {
|
||||||
let ratio = (seconds as f64) / (max_value as f64);
|
let ratio = (seconds as f64) / (max_value as f64);
|
||||||
let full_blocks = (ratio * (width as f64)) as usize;
|
let full_blocks = (ratio * (width as f64)) as usize;
|
||||||
let remainder = ((ratio * (width as f64) - full_blocks as f64) * 8.0) as usize;
|
let remainder = ((ratio * (width as f64) - full_blocks as f64) * 8.0) as usize;
|
||||||
|
|
||||||
let mut bar = String::new();
|
let mut bar = String::new();
|
||||||
for _ in 0..full_blocks {
|
for _ in 0..full_blocks {
|
||||||
bar.push_str(BLOCKS[7]);
|
bar.push_str(BLOCKS[7]);
|
||||||
|
@ -276,7 +276,7 @@ pub async fn status(settings: Settings) -> Result<(), CliError> {
|
||||||
let duration = now.naive_local().signed_duration_since(active_period.start_time);
|
let duration = now.naive_local().signed_duration_since(active_period.start_time);
|
||||||
let duration_str = format_duration(duration.num_seconds());
|
let duration_str = format_duration(duration.num_seconds());
|
||||||
println!("\n{}", "Current Session".bold());
|
println!("\n{}", "Current Session".bold());
|
||||||
println!("Active for: {} (started at {})",
|
println!("Active for: {} (started at {})",
|
||||||
duration_str.yellow(),
|
duration_str.yellow(),
|
||||||
active_period.start_time.format("%H:%M").to_string().yellow()
|
active_period.start_time.format("%H:%M").to_string().yellow()
|
||||||
);
|
);
|
||||||
|
@ -299,12 +299,6 @@ pub async fn status(settings: Settings) -> Result<(), CliError> {
|
||||||
|
|
||||||
const BOX_WIDTH: usize = 50;
|
const BOX_WIDTH: usize = 50;
|
||||||
const BAR_WIDTH: usize = 20;
|
const BAR_WIDTH: usize = 20;
|
||||||
|
|
||||||
// Print active session if exists
|
|
||||||
if status.active != "0" && status.active != "" {
|
|
||||||
println!("\n{}", "Current Session".bold());
|
|
||||||
println!("Active for: {}", status.active.yellow());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print weekly overview with visual bars
|
// Print weekly overview with visual bars
|
||||||
println!("\n{}", "Weekly Work Overview".bold());
|
println!("\n{}", "Weekly Work Overview".bold());
|
||||||
|
@ -315,19 +309,19 @@ pub async fn status(settings: Settings) -> Result<(), CliError> {
|
||||||
let date = week_start_date + chrono::Duration::days(i);
|
let date = week_start_date + chrono::Duration::days(i);
|
||||||
let seconds = daily.get(&date).cloned().unwrap_or(0);
|
let seconds = daily.get(&date).cloned().unwrap_or(0);
|
||||||
total += seconds;
|
total += seconds;
|
||||||
|
|
||||||
let day = date.format("%a").to_string().bold();
|
let day = date.format("%a").to_string().bold();
|
||||||
let duration = format_duration(seconds);
|
let duration = format_duration(seconds);
|
||||||
// Ensure the day and duration part is exactly 15 characters wide
|
// Ensure the day and duration part is exactly 15 characters wide
|
||||||
let day_str = format!("{:<3} {:<10}", day, duration);
|
let day_str = format!("{:<3} {:<10}", day, duration);
|
||||||
|
|
||||||
println!("{:<15} {:<width$}│",
|
println!("{:<15} {:<width$}│",
|
||||||
day_str,
|
day_str,
|
||||||
format_bar(seconds, max_seconds, BAR_WIDTH),
|
format_bar(seconds, max_seconds, BAR_WIDTH),
|
||||||
width = BOX_WIDTH - 15
|
width = BOX_WIDTH - 15
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("╰{}╯", "─".repeat(BOX_WIDTH));
|
println!("╰{}╯", "─".repeat(BOX_WIDTH));
|
||||||
println!("\nTotal Worked: {}", format_duration(total).bold());
|
println!("\nTotal Worked: {}", format_duration(total).bold());
|
||||||
|
|
||||||
|
@ -342,7 +336,7 @@ pub async fn status(settings: Settings) -> Result<(), CliError> {
|
||||||
println!("\n{}", "Extended Statistics".bold());
|
println!("\n{}", "Extended Statistics".bold());
|
||||||
println!("This Month: {}", status.month.cyan());
|
println!("This Month: {}", status.month.cyan());
|
||||||
println!("This Year: {}", status.year.cyan());
|
println!("This Year: {}", status.year.cyan());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,4 +344,4 @@ fn format_duration(seconds: i64) -> String {
|
||||||
let hours = seconds / 3600;
|
let hours = seconds / 3600;
|
||||||
let minutes = (seconds % 3600) / 60;
|
let minutes = (seconds % 3600) / 60;
|
||||||
format!("{}h {}m", hours, minutes)
|
format!("{}h {}m", hours, minutes)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue