From 1eb6661c7ea66f3e1451e04896fb8c7430a42e32 Mon Sep 17 00:00:00 2001 From: Bianca Yang <21014901+xrdt@users.noreply.github.com> Date: Mon, 3 Jun 2024 14:27:17 -0700 Subject: [PATCH] fix: Patch the usage_summary value for rows_synced (#22600) * patch the usage_summary value for rows_synced * break up code for readability --- ee/billing/billing_manager.py | 2 +- ee/billing/quota_limiting.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ee/billing/billing_manager.py b/ee/billing/billing_manager.py index 13ddb4cf5ce81..b30c265a35fff 100644 --- a/ee/billing/billing_manager.py +++ b/ee/billing/billing_manager.py @@ -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"], diff --git a/ee/billing/quota_limiting.py b/ee/billing/quota_limiting.py index 2acb336733c1d..856cd4dfa0e5f 100644 --- a/ee/billing/quota_limiting.py +++ b/ee/billing/quota_limiting.py @@ -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