Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix llm queries (#16006)

Max Brunsfeld240b7c641cb7
diff --git a/Procfile.postgrest b/Procfile.postgrest
new file mode 100644
index 00000000000..acab58e086c
--- /dev/null
+++ b/Procfile.postgrest
@@ -0,0 +1,2 @@
+app: postgrest crates/collab/postgrest_app.conf
+llm: postgrest crates/collab/postgrest_llm.conf
diff --git a/crates/collab/postgrest_app.conf b/crates/collab/postgrest_app.conf
new file mode 100644
index 00000000000..3a0cdfa4933
--- /dev/null
+++ b/crates/collab/postgrest_app.conf
@@ -0,0 +1,4 @@
+db-uri = "postgres://postgres@localhost/zed_llm"
+server-port = 8082
+jwt-secret = "the-postgrest-jwt-secret-for-authorization"
+log-level = "info"
diff --git a/crates/collab/admin_api.conf b/crates/collab/postgrest_llm.conf
similarity index 100%
rename from crates/collab/admin_api.conf
rename to crates/collab/postgrest_llm.conf
diff --git a/crates/collab/src/llm/db/queries/usages.rs b/crates/collab/src/llm/db/queries/usages.rs
index 206e5d39abe..6ea7439811b 100644
--- a/crates/collab/src/llm/db/queries/usages.rs
+++ b/crates/collab/src/llm/db/queries/usages.rs
@@ -173,12 +173,16 @@ impl LlmDatabase {
let users_in_recent_minutes = usage::Entity::find()
.filter(usage::Column::Timestamp.gte(minute_since.naive_utc()))
+ .select_only()
+ .column(usage::Column::UserId)
.group_by(usage::Column::UserId)
.count(&*tx)
.await? as usize;
let users_in_recent_days = usage::Entity::find()
.filter(usage::Column::Timestamp.gte(day_since.naive_utc()))
+ .select_only()
+ .column(usage::Column::UserId)
.group_by(usage::Column::UserId)
.count(&*tx)
.await? as usize;