Skip to content

Commit

Permalink
fix: Patch the usage_summary value for rows_synced (#22600)
Browse files Browse the repository at this point in the history
* patch the usage_summary value for rows_synced

* break up code for readability
  • Loading branch information
xrdt authored Jun 3, 2024
1 parent 9f5551a commit 1eb6661
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ee/billing/billing_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def update_org_details(self, organization: Organization, billing_status: Billing
usage_info = OrganizationUsageInfo(
events=usage_summary["events"],
recordings=usage_summary["recordings"],
rows_synced=usage_summary.get("rows_synced", None),
rows_synced=usage_summary.get("rows_synced", {}),
period=[
data["billing_period"]["current_period_start"],
data["billing_period"]["current_period_end"],
Expand Down
5 changes: 4 additions & 1 deletion ee/billing/quota_limiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,11 @@ def set_org_usage_summary(
if todays_usage:
resource_usage["todays_usage"] = todays_usage.get(field, 0)
else:
org_usage_data = organization.usage or {}
org_field_usage = org_usage_data.get(field, {}) or {}
org_usage = org_field_usage.get("usage")
# TRICKY: If we are not explictly setting todays_usage, we want to reset it to 0 IF the incoming new_usage is different
if (organization.usage or {}).get(field, {}).get("usage") != resource_usage.get("usage"):
if org_usage != resource_usage.get("usage"):
resource_usage["todays_usage"] = 0
else:
resource_usage["todays_usage"] = organization.usage.get(field, {}).get("todays_usage") or 0
Expand Down

0 comments on commit 1eb6661

Please sign in to comment.