diff options
Diffstat (limited to 'atuin-server-postgres')
| -rw-r--r-- | atuin-server-postgres/src/lib.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/atuin-server-postgres/src/lib.rs b/atuin-server-postgres/src/lib.rs index 404188b0..fe1363ac 100644 --- a/atuin-server-postgres/src/lib.rs +++ b/atuin-server-postgres/src/lib.rs @@ -101,6 +101,21 @@ impl Database for Postgres { } #[instrument(skip_all)] + async fn total_history(&self) -> DbResult<i64> { + // The cache is new, and the user might not yet have a cache value. + // They will have one as soon as they post up some new history, but handle that + // edge case. + + let res: (i64,) = sqlx::query_as("select sum(total) from total_history_count_user") + .fetch_optional(&self.pool) + .await + .map_err(fix_error)? + .unwrap_or((0,)); + + Ok(res.0) + } + + #[instrument(skip_all)] async fn count_history_cached(&self, user: &User) -> DbResult<i64> { let res: (i32,) = sqlx::query_as( "select total from total_history_count_user |
