Fix llm queries (#16006)

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
Max Brunsfeld 2024-08-08 17:21:38 -07:00 committed by GitHub
parent 06625bfe94
commit 240b7c641c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 0 deletions

2
Procfile.postgrest Normal file
View File

@ -0,0 +1,2 @@
app: postgrest crates/collab/postgrest_app.conf
llm: postgrest crates/collab/postgrest_llm.conf

View File

@ -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"

View File

@ -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;