{#
_time_in_status.html — Horizontal bar chart: time per status (Task F2).
Expected context:
time_in_status_view — result of time_in_status(): {per_status, bottleneck}
#}
{%- set tis = time_in_status_view -%}
Time in Status
avg days per status across ticket population
{%- if not tis.per_status %}
No status-transition history yet — start moving tickets to see bottleneck signals.
{%- else %}
{# Find max avg_days for bar scaling (exclude terminal statuses) #}
{%- set ns = namespace(max_avg=0.001) %}
{%- for row in tis.per_status %}
{%- if row.status not in ("done", "cancelled") and row.avg_days > ns.max_avg %}
{%- set ns.max_avg = row.avg_days %}
{%- endif %}
{%- endfor %}
{%- if tis.bottleneck %}
Bottleneck: {{ tis.bottleneck }} — highest avg wait time (non-terminal)