mirror of
https://github.com/atuinsh/atuin.git
synced 2024-11-29 03:34:44 +01:00
Fix deleted history count (#1328)
This commit is contained in:
parent
0b22d06ad3
commit
ce4573c5ee
@ -346,12 +346,13 @@ impl Database for Sqlite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn history_count(&self, include_deleted: bool) -> Result<i64> {
|
async fn history_count(&self, include_deleted: bool) -> Result<i64> {
|
||||||
let exclude_deleted: &str = if include_deleted { "" } else { "not" };
|
let query = if include_deleted {
|
||||||
let query = format!(
|
"select count(1) from history"
|
||||||
"select count(1) from history where deleted_at is {} null",
|
} else {
|
||||||
exclude_deleted
|
"select count(1) from history where deleted_at is null"
|
||||||
);
|
};
|
||||||
let res: (i64,) = sqlx::query_as(&query).fetch_one(&self.pool).await?;
|
|
||||||
|
let res: (i64,) = sqlx::query_as(query).fetch_one(&self.pool).await?;
|
||||||
Ok(res.0)
|
Ok(res.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ pub async fn run(settings: &Settings, db: &impl Database) -> Result<()> {
|
|||||||
let status = client.status().await?;
|
let status = client.status().await?;
|
||||||
let last_sync = Settings::last_sync()?;
|
let last_sync = Settings::last_sync()?;
|
||||||
let local_count = db.history_count(false).await?;
|
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");
|
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!("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 {
|
if settings.auto_sync {
|
||||||
println!("{}", "[Remote]".green());
|
println!("{}", "[Remote]".green());
|
||||||
|
Loading…
Reference in New Issue
Block a user