{# Badge for execution, recipient and report states (ADR 0001). #}
{% macro state_badge(state) -%}
{%- if state in ('SUCCEEDED', 'ACCEPTED', 'SUCCESS') -%}
{{ state }}
{%- elif state in ('FAILED', 'PERMANENT_FAILURE', 'RETRY_EXHAUSTED', 'EXPIRED', 'WINDOW_EXPIRED') -%}
{{ state }}
{%- elif state in ('PARTIAL', 'RETRY_WAIT', 'NEEDS_REVIEW', 'UNKNOWN', 'IN_FLIGHT') -%}
{{ state }}
{%- else -%}
{{ state }}
{%- endif -%}
{%- endmacro %}
{# What a message is sent for: the cadence values of a SendContext (or None). #}
{% macro send_context_line(context) -%}
{%- if context -%}
Sent for {{ context.date.isoformat() }}
{%- if context.window_start %} · window {{ context.window_start.strftime('%Y-%m-%d %H:%M') }}
– {{ context.window_end.strftime('%Y-%m-%d %H:%M') }}{% else %} · no window{% endif %}
· {{ context.timezone }} · {{ "manual send" if context.kind == "manual" else "scheduled send" }}
{%- else -%}
Send context not stored (claimed before version 0.10)
{%- endif -%}
{%- endmacro %}