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 full_blocks = (ratio * (width as f64)) as usize;
|
||||
let remainder = ((ratio * (width as f64) - full_blocks as f64) * 8.0) as usize;
|
||||
|
||||
|
||||
let mut bar = String::new();
|
||||
for _ in 0..full_blocks {
|
||||
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_str = format_duration(duration.num_seconds());
|
||||
println!("\n{}", "Current Session".bold());
|
||||
println!("Active for: {} (started at {})",
|
||||
println!("Active for: {} (started at {})",
|
||||
duration_str.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 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
|
||||
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 seconds = daily.get(&date).cloned().unwrap_or(0);
|
||||
total += seconds;
|
||||
|
||||
|
||||
let day = date.format("%a").to_string().bold();
|
||||
let duration = format_duration(seconds);
|
||||
// Ensure the day and duration part is exactly 15 characters wide
|
||||
let day_str = format!("{:<3} {:<10}", day, duration);
|
||||
|
||||
println!("{:<15} {:<width$}│",
|
||||
|
||||
println!("{:<15} {:<width$}│",
|
||||
day_str,
|
||||
format_bar(seconds, max_seconds, BAR_WIDTH),
|
||||
width = BOX_WIDTH - 15
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
println!("╰{}╯", "─".repeat(BOX_WIDTH));
|
||||
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!("This Month: {}", status.month.cyan());
|
||||
println!("This Year: {}", status.year.cyan());
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -350,4 +344,4 @@ fn format_duration(seconds: i64) -> String {
|
|||
let hours = seconds / 3600;
|
||||
let minutes = (seconds % 3600) / 60;
|
||||
format!("{}h {}m", hours, minutes)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue