summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2022-04-21 09:19:54 +0100
committerGitHub <noreply@github.com>2022-04-21 09:19:54 +0100
commit24e297178776ca3e5d71cdf446e4394e7a1bcb5c (patch)
tree22862e4235ff0be94bc5aab848865b9def778700
parentfe05d86bfaf42945ad7fb345693873451f128779 (diff)
Fix SQL cache query (#318)
I just deployed the older version and it was falling back on the full count. Turns out this is because it won't upcast from INT4 to INT8 automatically, and it has to be manual At some point the underlying total should be changed to int8, but also I highly doubt anyone will have enough shell history to fill an int4 lol
-rw-r--r--atuin-server/src/database.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/atuin-server/src/database.rs b/atuin-server/src/database.rs
index e163d3a7..efde86a3 100644
--- a/atuin-server/src/database.rs
+++ b/atuin-server/src/database.rs
@@ -120,7 +120,7 @@ impl Database for Postgres {
}
async fn count_history_cached(&self, user: &User) -> Result<i64> {
- let res: (i64,) = sqlx::query_as(
+ let res: (i32,) = sqlx::query_as(
"select total from total_history_count_user
where user_id = $1",
)
@@ -128,7 +128,7 @@ impl Database for Postgres {
.fetch_one(&self.pool)
.await?;
- Ok(res.0)
+ Ok(res.0 as i64)
}
async fn count_history_range(