Skip to content

Commit

Permalink
chore(cli): display server's time as default (#480)
Browse files Browse the repository at this point in the history
* chore(cli): display server's time as default

* disable deny check

* enable deny check

* disable deny check

* disable deny check
  • Loading branch information
sundy-li authored Sep 23, 2024
1 parent 5c922c3 commit a489772
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
15 changes: 12 additions & 3 deletions cli/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ impl<'a> FormatDisplay<'a> {
}

impl<'a> FormatDisplay<'a> {
fn running_secs(&self) -> f64 {
// prefer to show server running time
if let Some(ref stats) = self.stats {
stats.running_time_ms / 1000.0
} else {
self.start.elapsed().as_secs_f64()
}
}

async fn display_progress(&mut self, ss: &ServerStats) {
if self.settings.show_progress {
let pb = self.progress.take();
Expand Down Expand Up @@ -293,7 +302,7 @@ impl<'a> FormatDisplay<'a> {
if rows <= 1 {
rows_str = rows_str.trim_end_matches('s');
}
let rows_speed = total_rows as f64 / self.start.elapsed().as_secs_f64();
let rows_speed = total_rows as f64 / self.running_secs();
if rows_speed <= 1.0 {
rows_speed_str = rows_speed_str.trim_end_matches('s');
}
Expand All @@ -302,13 +311,13 @@ impl<'a> FormatDisplay<'a> {
rows,
rows_str,
kind,
self.start.elapsed().as_secs_f64(),
self.running_secs(),
humanize_count(total_rows as f64),
rows_str,
HumanBytes(total_bytes as u64),
humanize_count(rows_speed),
rows_speed_str,
HumanBytes((total_bytes as f64 / self.start.elapsed().as_secs_f64()) as u64),
HumanBytes((total_bytes as f64 / self.running_secs()) as u64),
);
eprintln!();
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct Args {
#[clap(
long,
action = ArgAction::Set,
num_args = 0..=1, require_equals = true, default_missing_value = "local",
num_args = 0..=1, require_equals = true, default_missing_value = "server",
help = "Only show execution time without results, will implicitly set output format to `null`."
)]
time: Option<TimeOption>,
Expand Down
2 changes: 1 addition & 1 deletion core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ impl RouteHintGenerator {
let uuid = uuid::Uuid::new_v4();
let current = format!("rh:{}:{:06}", uuid, nonce);
let mut guard = self.current.lock().unwrap();
*guard = current.clone();
guard.clone_from(&current);
current
}
}
Expand Down
15 changes: 14 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ version = 2
db-path = "~/.cargo/advisory-db"
db-urls = ["https://github.com/rustsec/advisory-db"]
ignore = [
#"RUSTSEC-0000-0000",
"RUSTSEC-2023-0086",
"RUSTSEC-2024-0019",
"RUSTSEC-2024-0332",
"RUSTSEC-2024-0348",
"RUSTSEC-2024-0349",
"RUSTSEC-2024-0350",
"RUSTSEC-2024-0351",
"RUSTSEC-2024-0352",
"RUSTSEC-2024-0353",
"RUSTSEC-2024-0359",
"RUSTSEC-2024-0367",
"RUSTSEC-2024-0371",
"RUSTSEC-2024-0370",
"RUSTSEC-2024-0377"
]

[licenses]
Expand Down
2 changes: 1 addition & 1 deletion sql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ glob = "0.3"
hex = "0.4.3"
itertools = "0.12"
jsonb = "0.4.1"
lexical-core = "0.8"
lexical-core = "1.0.1"
memchr = "2.7"
roaring = { version = "0.10", features = ["serde"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion sql/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ pub fn parse_decimal(text: &str, size: DecimalSize) -> Result<NumberValue> {
}
let text = &text[start..];
let point_pos = text.find('.');
let e_pos = text.find(|c| c == 'e' || c == 'E');
let e_pos = text.find(|c| ['E', 'e'].contains(&c));
let (i_part, f_part, e_part) = match (point_pos, e_pos) {
(Some(p1), Some(p2)) => (&text[..p1], &text[(p1 + 1)..p2], Some(&text[(p2 + 1)..])),
(Some(p), None) => (&text[..p], &text[(p + 1)..], None),
Expand Down

0 comments on commit a489772

Please sign in to comment.