{% set total_votes = resblob.FPTP_result.total_votes | default(0) %} {% if total_votes == 0 %}
  • Total ballots: 0
  • No first-place votes recorded for this contest.
  • {% else %} {% set winners = resblob['FPTP_result']['winners'] %} {% set winnerstr = ", ".join(winners) %} {% set winnerintro = "FPTP Winners (tie)" if winners | length > 1 else "FPTP Winner" %}
  • {{winnerintro}}: {% if FPTP_candnames %} {%- for winner in winners -%} {{ FPTP_candnames[winner] if winner in FPTP_candnames else winner }}{% if not loop.last %}, {% endif %} {%- endfor -%} {% else %} {{ winnerstr }} {% endif %} {% if winners and resblob.FPTP_result.toppicks %} {% set winner_votes = resblob.FPTP_result.toppicks[winners[0]] %} with {{ "{:,}".format(winner_votes) }} first-place votes ({{ "%0.1f"|format((winner_votes / resblob.FPTP_result.total_votes) * 100) if resblob.FPTP_result.total_votes > 0 else 0 }}%) {% endif %}
  • {% if winners and resblob.FPTP_result.toppicks %} {% set winner_votes = resblob.FPTP_result.toppicks[winners[0]] %} {# Build candidate list excluding None for runner-up computation #} {% set sorted_candidates = resblob.FPTP_result.toppicks.items() | list %} {% set sorted_candidates = sorted_candidates | selectattr('0', 'ne', None) | list %} {% set sorted_candidates = sorted_candidates | sort(attribute='1', reverse=true) %} {% if sorted_candidates|length > 1 %} {% set runner_up = sorted_candidates[1] %}
  • Runner-up: {{ FPTP_candnames[runner_up[0]] if FPTP_candnames and runner_up[0] in FPTP_candnames else runner_up[0] }} with {{ "{:,}".format(runner_up[1]) }} first-place votes ({{ "%0.1f"|format((runner_up[1] / resblob.FPTP_result.total_votes) * 100) if resblob.FPTP_result.total_votes > 0 else 0 }}%)
  • Margin of victory: {{ "{:,}".format(winner_votes - runner_up[1]) }} votes ({{ "%0.1f"|format(((winner_votes - runner_up[1]) / resblob.FPTP_result.total_votes) * 100) if resblob.FPTP_result.total_votes > 0 else 0 }} percentage points)
  • {% endif %} {% endif %}
  • First-place votes
      {% for candidate, votes in resblob.FPTP_result.toppicks|dictsort(reverse=true, by='value') %} {% if candidate is not none %}
    • {{ FPTP_candnames[candidate] if FPTP_candnames and candidate in FPTP_candnames else candidate }}: {{ "{:,}".format(votes) }} votes {% if resblob.FPTP_result.total_votes > 0 %} ({{ "%0.1f"|format((votes / resblob.FPTP_result.total_votes) * 100) }} %) {% endif %}
    • {% endif %} {% endfor %}
  • {% set overvotes = resblob.FPTP_result.get('overvote_ballots', resblob.FPTP_result.get('invalid_ballots', 0)) %} {% set none_total = resblob.FPTP_result.toppicks.get(None, 0) %} {% set blanks = (none_total - overvotes) if (none_total is not none) else 0 %} {% if overvotes > 0 %}
  • Overvotes: {{ "{:,}".format(overvotes) }}{% if resblob.FPTP_result.total_votes > 0 %} ({{ "%0.1f"|format((overvotes / resblob.FPTP_result.total_votes) * 100) }} %){% endif %}
  • {% endif %} {% if blanks > 0 %}
  • Blanks: {{ "{:,}".format(blanks) }}{% if resblob.FPTP_result.total_votes > 0 %} ({{ "%0.1f"|format((blanks / resblob.FPTP_result.total_votes) * 100) }} %){% endif %}
  • {% endif %}
  • Total ballots: {{ "{:,}".format(resblob.FPTP_result.total_votes) }}
  • {% endif %}