Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
collab: Rename symbols for existing Stripe synchronization (#29570)
Marshall Bowers9abeedf0c6e0
diff --git a/crates/collab/src/api/billing.rs b/crates/collab/src/api/billing.rsindex b635f3daa14..507c3435d01 100644--- a/crates/collab/src/api/billing.rs+++ b/crates/collab/src/api/billing.rs@@ -1243,9 +1243,9 @@ async fn find_or_create_billing_customer(Ok(Some(billing_customer))}-const SYNC_LLM_USAGE_WITH_STRIPE_INTERVAL: Duration = Duration::from_secs(60);+const SYNC_LLM_TOKEN_USAGE_WITH_STRIPE_INTERVAL: Duration = Duration::from_secs(60);-pub fn sync_llm_usage_with_stripe_periodically(app: Arc<AppState>) {+pub fn sync_llm_token_usage_with_stripe_periodically(app: Arc<AppState>) {let Some(stripe_billing) = app.stripe_billing.clone() else {log::warn!("failed to retrieve Stripe billing object");return;@@ -1260,17 +1260,19 @@ pub fn sync_llm_usage_with_stripe_periodically(app: Arc<AppState>) {let executor = executor.clone();async move {loop {- sync_with_stripe(&app, &llm_db, &stripe_billing)+ sync_token_usage_with_stripe(&app, &llm_db, &stripe_billing).await.context("failed to sync LLM usage to Stripe").trace_err();- executor.sleep(SYNC_LLM_USAGE_WITH_STRIPE_INTERVAL).await;+ executor+ .sleep(SYNC_LLM_TOKEN_USAGE_WITH_STRIPE_INTERVAL)+ .await;}}});}-async fn sync_with_stripe(+async fn sync_token_usage_with_stripe(app: &Arc<AppState>,llm_db: &Arc<LlmDatabase>,stripe_billing: &Arc<StripeBilling>,@@ -1306,7 +1308,7 @@ async fn sync_with_stripe(.subscribe_to_model(&stripe_subscription_id, &stripe_model).await?;stripe_billing- .bill_model_usage(&stripe_customer_id, &stripe_model, &event)+ .bill_model_token_usage(&stripe_customer_id, &stripe_model, &event).await?;llm_db.consume_billing_event(event.id).await?;}diff --git a/crates/collab/src/main.rs b/crates/collab/src/main.rsindex a363d556a1f..25befc28459 100644--- a/crates/collab/src/main.rs+++ b/crates/collab/src/main.rs@@ -8,7 +8,7 @@ use axum::{};use collab::api::CloudflareIpCountryHeader;-use collab::api::billing::sync_llm_usage_with_stripe_periodically;+use collab::api::billing::sync_llm_token_usage_with_stripe_periodically;use collab::llm::db::LlmDatabase;use collab::migrations::run_database_migrations;use collab::user_backfiller::spawn_user_backfiller;@@ -152,7 +152,7 @@ async fn main() -> Result<()> {if let Some(mut llm_db) = llm_db {llm_db.initialize().await?;- sync_llm_usage_with_stripe_periodically(state.clone());+ sync_llm_token_usage_with_stripe_periodically(state.clone());}app = appdiff --git a/crates/collab/src/stripe_billing.rs b/crates/collab/src/stripe_billing.rsindex 97c6ee4fb89..e992187a9c5 100644--- a/crates/collab/src/stripe_billing.rs+++ b/crates/collab/src/stripe_billing.rs@@ -268,7 +268,7 @@ impl StripeBilling {Ok(())}- pub async fn bill_model_usage(+ pub async fn bill_model_token_usage(&self,customer_id: &stripe::CustomerId,model: &StripeModel,