{# _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 %} {%- for row in tis.per_status %} {%- set y = loop.index0 * 44 + 4 %} {%- set is_bottleneck = (row.status == tis.bottleneck) %} {%- set is_terminal = row.status in ("done", "cancelled") %} {%- set bar_pct = (row.avg_days / ns.max_avg * 100) | round(1) if not is_terminal else 0 %} {%- set bar_w = (bar_pct / 100 * 340) | round(1) %} {# Status label #} {{ row.status }} {# Bar track #} {# Bar fill #} {%- if bar_w > 0 %} {%- endif %} {# Avg label #} {{ row.avg_days }}d {# Ticket count #} {{ row.ticket_count }}t {# Bottleneck indicator #} {%- if is_bottleneck %} {%- endif %} {%- endfor %} {%- if tis.bottleneck %}
Bottleneck: {{ tis.bottleneck }} — highest avg wait time (non-terminal)
{%- endif %} {%- endif %}