Skip to content

Commit

Permalink
Fix deleted history count (#1328)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellie committed Oct 25, 2023
1 parent 0b22d06 commit ce4573c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions atuin-client/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 3 additions & 1 deletion atuin/src/command/client/sync/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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());
Expand Down

1 comment on commit ce4573c

@vercel
Copy link

@vercel vercel bot commented on ce4573c Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

atuin-docs – ./

atuin-docs-git-main-atuin.vercel.app
atuin-docs.vercel.app
atuin-docs-atuin.vercel.app

Please sign in to comment.