Aug 21 - Fix plan usage counter

This commit is contained in:
2026-08-21 09:40:25 -04:00
parent 6371b13c13
commit cb7c244872
4 changed files with 211 additions and 20 deletions
+10 -5
View File
@@ -98,17 +98,22 @@
('facilities', 'Active Facilities (total)', plan_info.max_facilities),
] %}
{% for key, label, limit in axes %}
{% set current = quota_usage.get(key, 0) %}
{% set pct = ((current / limit * 100) | int) if limit else 0 %}
{% set over = limit and current >= limit %}
{# None = the counter failed (logged server-side). Rendered as "—"
rather than 0 so an unknown count is never mistaken for real usage. #}
{% set current = quota_usage.get(key) %}
{% set unknown = current is none %}
{% set pct = ((current / limit * 100) | int) if (limit and not unknown) else 0 %}
{% set over = limit and not unknown and current >= limit %}
<div class="mb-3">
<div class="d-flex justify-content-between mb-1" style="font-size:.85rem;">
<span>{{ label }}</span>
<span class="{{ 'text-danger fw-semibold' if over else 'text-muted' }}">
{{ current }}{% if limit %} / {{ limit }}{% else %} / <em>unlimited</em>{% endif %}
{% if unknown %}
<span title="This count could not be read — see the server log.">&mdash;</span>
{% else %}{{ current }}{% endif %}{% if limit %} / {{ limit }}{% else %} / <em>unlimited</em>{% endif %}
</span>
</div>
{% if limit %}
{% if limit and not unknown %}
<div class="progress" style="height:6px;">
<div class="progress-bar {{ 'bg-danger' if over else ('bg-warning' if pct >= 80 else 'bg-success') }}"
role="progressbar" style="width:{{ [pct,100]|min }}%"></div>