Skip to content

Commit

Permalink
personal usage only account org that has workspace limit
Browse files Browse the repository at this point in the history
  • Loading branch information
lyang2821 committed Oct 12, 2024
1 parent 92451e1 commit 84f29cf
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lapdev-enterprise/src/enterprise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,21 @@ impl Enterprise {
let all_orgs = self.db.get_user_organizations(user_id).await?;
if all_orgs.len() > 1 {
let mut personal_usage = 0;
for org in all_orgs {
let usage = self
.usage
.get_monthly_cost(
org.organization_id,
Some(user_id),
Utc::now().into(),
None,
)
.await?;
personal_usage += usage;
for member in all_orgs {
if let Ok(org) = self.db.get_organization(member.organization_id).await {
if org.running_workspace_limit > 0 {
let usage = self
.usage
.get_monthly_cost(
org.id,
Some(user_id),
Utc::now().into(),
None,
)
.await?;
personal_usage += usage;
}
}
}
if personal_usage as i64 >= organization.usage_limit {
return Err(ApiError::InvalidRequest(
Expand Down

0 comments on commit 84f29cf

Please sign in to comment.