mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 21:32:40 +00:00
f861479890
This PR reworks our existing billing code in preparation for charging based on LLM usage. We aren't yet exercising the new billing-related code outside of development. There are some noteworthy changes for our existing LLM usage tracking: - A new `monthly_usages` table has been added for tracking usage per-user, per-model, per-month - The per-month usage measures have been removed, in favor of the `monthly_usages` table - All of the per-month metrics in the Clickhouse rows have been changed from a rolling 30-day window to a calendar month Release Notes: - N/A --------- Co-authored-by: Antonio Scandurra <me@as-cii.com> Co-authored-by: Richard <richard@zed.dev> Co-authored-by: Max <max@zed.dev>
13 lines
542 B
SQL
13 lines
542 B
SQL
create table monthly_usages (
|
|
id serial primary key,
|
|
user_id integer not null,
|
|
model_id integer not null references models (id) on delete cascade,
|
|
month integer not null,
|
|
year integer not null,
|
|
input_tokens bigint not null default 0,
|
|
cache_creation_input_tokens bigint not null default 0,
|
|
cache_read_input_tokens bigint not null default 0,
|
|
output_tokens bigint not null default 0
|
|
);
|
|
|
|
create unique index uix_monthly_usages_on_user_id_model_id_month_year on monthly_usages (user_id, model_id, month, year);
|