collab: Don't try to sync usage to Stripe for staff users (#29892)
This PR makes it so we don't try to sync billing usage to Stripe for staff users. Release Notes: - N/A
This commit is contained in:
parent
76ad1a29a5
commit
3594a52bee
2 changed files with 22 additions and 0 deletions
|
@ -1496,9 +1496,19 @@ async fn sync_model_request_usage_with_stripe(
|
|||
llm_db: &Arc<LlmDatabase>,
|
||||
stripe_billing: &Arc<StripeBilling>,
|
||||
) -> anyhow::Result<()> {
|
||||
let staff_users = app.db.get_staff_users().await?;
|
||||
let staff_user_ids = staff_users
|
||||
.iter()
|
||||
.map(|user| user.id)
|
||||
.collect::<HashSet<UserId>>();
|
||||
|
||||
let usage_meters = llm_db
|
||||
.get_current_subscription_usage_meters(Utc::now())
|
||||
.await?;
|
||||
let usage_meters = usage_meters
|
||||
.into_iter()
|
||||
.filter(|(_, usage)| !staff_user_ids.contains(&usage.user_id))
|
||||
.collect::<Vec<_>>();
|
||||
let user_ids = usage_meters
|
||||
.iter()
|
||||
.map(|(_, usage)| usage.user_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue