aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client/src/record
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-04-17 14:06:05 +0100
committerGitHub <noreply@github.com>2024-04-17 14:06:05 +0100
commitcb19925011d889c513e1bbedc446e399597e38a0 (patch)
tree7ad9e42013e15957805f2cdf563ce8b3e0c770f5 /atuin-client/src/record
parentchore(deps): bump debian (#1947) (diff)
downloadatuin-cb19925011d889c513e1bbedc446e399597e38a0.zip
feat(gui): work on home page, sort state (#1956)
1. Start on a home page, can sort onboarding/etc from there 2. Introduce zustand for state management. It's nice! Did a production build and clicked around for a while. Memory usage seems nice and chill.
Diffstat (limited to 'atuin-client/src/record')
-rw-r--r--atuin-client/src/record/sqlite_store.rs10
-rw-r--r--atuin-client/src/record/store.rs1
2 files changed, 11 insertions, 0 deletions
diff --git a/atuin-client/src/record/sqlite_store.rs b/atuin-client/src/record/sqlite_store.rs
index e17893eb..31de311b 100644
--- a/atuin-client/src/record/sqlite_store.rs
+++ b/atuin-client/src/record/sqlite_store.rs
@@ -180,6 +180,16 @@ impl Store for SqliteStore {
self.idx(host, tag, 0).await
}
+ async fn len_all(&self) -> Result<u64> {
+ let res: Result<(i64,), sqlx::Error> = sqlx::query_as("select count(*) from store")
+ .fetch_one(&self.pool)
+ .await;
+ match res {
+ Err(e) => Err(eyre!("failed to fetch local store len: {}", e)),
+ Ok(v) => Ok(v.0 as u64),
+ }
+ }
+
async fn len_tag(&self, tag: &str) -> Result<u64> {
let res: Result<(i64,), sqlx::Error> =
sqlx::query_as("select count(*) from store where tag=?1")
diff --git a/atuin-client/src/record/store.rs b/atuin-client/src/record/store.rs
index 188e18ce..49ca4968 100644
--- a/atuin-client/src/record/store.rs
+++ b/atuin-client/src/record/store.rs
@@ -25,6 +25,7 @@ pub trait Store {
async fn delete(&self, id: RecordId) -> Result<()>;
async fn delete_all(&self) -> Result<()>;
+ async fn len_all(&self) -> Result<u64>;
async fn len(&self, host: HostId, tag: &str) -> Result<u64>;
async fn len_tag(&self, tag: &str) -> Result<u64>;