Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 2 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 4 additions & 48 deletions src/execution/stats.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
use crate::prelude::*;
use owo_colors::{AnsiColors, OwoColorize};

use std::{
ops::AddAssign,
sync::atomic::{AtomicI64, Ordering::Relaxed},
};

/// Check if stdout is a TTY
fn is_stdout_tty() -> bool {
atty::is(atty::Stream::Stdout)
}

#[derive(Default, Serialize)]
pub struct Counter(pub AtomicI64);

Expand Down Expand Up @@ -235,16 +229,7 @@ impl std::fmt::Display for UpdateStats {

// Error handling
if num_errors > 0 {
let tty = is_stdout_tty();
if tty {
write!(
f,
"{}",
format!("{} rows failed", num_errors).color(AnsiColors::White)
)?;
} else {
write!(f, "{} rows failed", num_errors)?;
}
write!(f, "{} rows failed", num_errors)?;
if !segments.is_empty() {
write!(f, "; ")?;
}
Expand Down Expand Up @@ -297,19 +282,8 @@ impl std::fmt::Display for UpdateStats {
if remaining_width > 0 {
bar.push_str(&" ".repeat(remaining_width));
}
let tty = is_stdout_tty();
// Use total from current operations - this represents the actual record count
if tty {
write!(
f,
"[{}] {}/{} records ",
bar.color(AnsiColors::BrightBlack),
total - num_in_process,
total
)?;
} else {
write!(f, "[{}] {}/{} records ", bar, total - num_in_process, total)?;
}
write!(f, "[{}] {}/{} records ", bar, total - num_in_process, total)?;

// Add segment labels with different grey shades for each segment type
let mut first = true;
Expand All @@ -318,16 +292,7 @@ impl std::fmt::Display for UpdateStats {
if !first {
write!(f, " ")?;
}
if tty {
match *segment_type {
"+" => write!(f, "{}", label.color(AnsiColors::BrightBlack))?, // Lightest grey for additions
"-" => write!(f, "{}", label.color(AnsiColors::White))?, // White for removals
"~" => write!(f, "{}", label.color(AnsiColors::Black))?, // Dark grey for updates
_ => write!(f, "{}", label.color(AnsiColors::Black))?, // Black for no-change
}
} else {
write!(f, "{}", label)?;
}
write!(f, "{}", label)?;
first = false;
}
}
Expand All @@ -340,16 +305,7 @@ impl std::fmt::Display for UpdateStats {
if !segments.is_empty() {
write!(f, " ")?;
}
let tty = is_stdout_tty();
if tty {
write!(
f,
"{}",
format!("({} in process)", num_in_process).color(AnsiColors::Black)
)?;
} else {
write!(f, "({} in process)", num_in_process)?;
}
write!(f, "({} in process)", num_in_process)?;
}

Ok(())
Expand Down
Loading