summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2023-10-25 20:54:20 +0100
committerGitHub <noreply@github.com>2023-10-25 20:54:20 +0100
commitce4573c5eea904c77773f2c2b8a7b6cd74977f15 (patch)
treed2fc5c13a8ac1a843ecad7cfd1d4448fbf16f2a4
parent0b22d06ad3586ef5e9486a4768feaa8f6d0ddb80 (diff)
Fix deleted history count (#1328)
-rw-r--r--atuin-client/src/database.rs13
-rw-r--r--atuin/src/command/client/sync/status.rs4
2 files changed, 10 insertions, 7 deletions
diff --git a/atuin-client/src/database.rs b/atuin-client/src/database.rs
index a7be9436d..2e4211aaa 100644
--- a/atuin-client/src/database.rs
+++ b/atuin-client/src/database.rs
@@ -346,12 +346,13 @@ impl Database for Sqlite {
}
async fn history_count(&self, include_deleted: bool) -> Result<i64> {
- let exclude_deleted: &str = if include_deleted { "" } else { "not" };
- let query = format!(
- "select count(1) from history where deleted_at is {} null",
- exclude_deleted
- );
- let res: (i64,) = sqlx::query_as(&query).fetch_one(&self.pool).await?;
+ let query = if include_deleted {
+ "select count(1) from history"
+ } else {
+ "select count(1) from history where deleted_at is null"
+ };
+
+ let res: (i64,) = sqlx::query_as(query).fetch_one(&self.pool).await?;
Ok(res.0)
}
diff --git a/atuin/src/command/client/sync/status.rs b/atuin/src/command/client/sync/status.rs
index a4d6bbd32..a03ebb4ca 100644
--- a/atuin/src/command/client/sync/status.rs
+++ b/atuin/src/command/client/sync/status.rs
@@ -14,6 +14,7 @@ pub async fn run(settings: &Settings, db: &impl Database) -> Result<()> {
let status = client.status().await?;
let last_sync = Settings::last_sync()?;
let local_count = db.history_count(false).await?;
+ let deleted_count = db.history_count(true).await? - local_count;
println!("Atuin v{VERSION} - Build rev {SHA}\n");
@@ -24,7 +25,8 @@ pub async fn run(settings: &Settings, db: &impl Database) -> Result<()> {
println!("Last sync: {last_sync}");
}
- println!("History count: {local_count}\n");
+ println!("History count: {local_count}");
+ println!("Deleted history count: {deleted_count}\n");
if settings.auto_sync {
println!("{}", "[Remote]".green());