From cb19925011d889c513e1bbedc446e399597e38a0 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Wed, 17 Apr 2024 14:06:05 +0100 Subject: 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. --- atuin-client/src/record/sqlite_store.rs | 10 ++++++++++ atuin-client/src/record/store.rs | 1 + 2 files changed, 11 insertions(+) (limited to 'atuin-client/src/record') 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 { + 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 { 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; async fn len(&self, host: HostId, tag: &str) -> Result; async fn len_tag(&self, tag: &str) -> Result; -- cgit v1.3.1