Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
support: Handle missing current licenses data for support views.
Lauryn Menardea725aaaf3c5
diff --git a/corporate/lib/support.py b/corporate/lib/support.pyindex 26775db2265..4653703141d 100644--- a/corporate/lib/support.py+++ b/corporate/lib/support.py@@ -10,6 +10,7 @@ from django.utils.timezone import now as timezone_nowfrom corporate.lib.stripe import BillingSessionfrom corporate.models import Customer, CustomerPlan, get_current_plan_by_customerfrom zerver.models import Realm, get_realm+from zilencer.lib.remote_counts import MissingDataError@dataclass@@ -19,6 +20,7 @@ class PlanData:licenses: Optional[int] = Nonelicenses_used: Optional[int] = Noneis_legacy_plan: bool = False+ warning: Optional[str] = Nonedef get_support_url(realm: Realm) -> str:@@ -55,7 +57,10 @@ def get_current_plan_data_for_support_view(billing_session: BillingSession) -> Pif new_plan is not None:plan_data.current_plan = new_plan # nocoverageplan_data.licenses = last_ledger_entry.licenses- plan_data.licenses_used = billing_session.current_count_for_billed_licenses()+ try:+ plan_data.licenses_used = billing_session.current_count_for_billed_licenses()+ except MissingDataError: # nocoverage+ plan_data.warning = "Recent data missing: No information for used licenses"assert plan_data.current_plan is not None # for mypyplan_data.is_legacy_plan = (plan_data.current_plan.tier == CustomerPlan.TIER_SELF_HOSTED_LEGACYdiff --git a/templates/analytics/current_plan_details.html b/templates/analytics/current_plan_details.htmlindex d123670915f..c25b0995248 100644--- a/templates/analytics/current_plan_details.html+++ b/templates/analytics/current_plan_details.html@@ -1,4 +1,10 @@<h4>📅 Current plan information:</h4>+{% if plan_data.warning %}+<div class="current-plan-data-missing">+ {{ plan_data.warning }}+ <br />+</div>+{% endif %}<b>Plan name</b>: {{ plan_data.current_plan.name }}<br /><b>Status</b>: {{ plan_data.current_plan.get_plan_status_as_text() }}<br />{% if plan_data.is_legacy_plan %}diff --git a/web/styles/portico/activity.css b/web/styles/portico/activity.cssindex 12e99c1bfe9..cbc9a8bb767 100644--- a/web/styles/portico/activity.css+++ b/web/styles/portico/activity.css@@ -85,6 +85,7 @@ tr.admin td:first-child {color: hsl(120deg 100% 33%);}+.current-plan-data-missing,.bad {font-weight: bold;color: hsl(0deg 100% 39%);