From 240b7c641cb7ed0957823c87d1faa6dfd426a7c3 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 8 Aug 2024 17:21:38 -0700 Subject: [PATCH] Fix llm queries (#16006) Release Notes: - N/A --------- Co-authored-by: Marshall --- Procfile.postgrest | 2 ++ crates/collab/postgrest_app.conf | 4 ++++ crates/collab/{admin_api.conf => postgrest_llm.conf} | 0 crates/collab/src/llm/db/queries/usages.rs | 4 ++++ 4 files changed, 10 insertions(+) create mode 100644 Procfile.postgrest create mode 100644 crates/collab/postgrest_app.conf rename crates/collab/{admin_api.conf => postgrest_llm.conf} (100%) diff --git a/Procfile.postgrest b/Procfile.postgrest new file mode 100644 index 0000000000..acab58e086 --- /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 0000000000..3a0cdfa493 --- /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 206e5d39ab..6ea7439811 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;