{% extends "base.html" %}
{% block heading %}
Recent Invocations
{% endblock %}

{% block content %}
{% if filter_info %}
<h1>Invocations filtered by {{ filter_info | e }}</h1>

<a href="/">(all invocations)</a>
{% else %}
<h1>Recent Invocations</h1>
Filter by:
  <a href="/filterinvocations/noncached">only not fully cached</a>
  {% if context_filters %}
  <details>
    <summary>Context</summary>
    {% for entry in context_filters %}
      <tt>{{ entry.key | e }}</tt>:
      {% for value in entry["values"] %}
        {% if loop.index > 1 %}
        ,
        {% endif %}
        <a href="/filterinvocations/context/{{ entry["key_hex"] | e }}/{{ value["value_hex"] | e }}"><tt>{{ value["value"] | e }}</tt></a>
      {% endfor %}<br>
    {% endfor %}
  </details>
  {% endif %}
  {% if remote_props_filters %}
  <details>
    <summary>Remote properties</summary>
    {% for entry in remote_props_filters %}
      <tt>{{ entry.key | e }}</tt>:
      {% for value in entry["values"] %}
        {% if loop.index > 1 %}
        ,
        {% endif %}
        <a href="/filterinvocations/remote/prop/{{ entry["key_hex"] | e }}/{{ value["value_hex"] | e }}"><tt>{{ value["value"] | e }}</tt></a>
      {% endfor %}<br>
    {% endfor %}
  </details>
  {% endif %}
  {% if remote_address_filters %}
  <details>
    <summary>Remote address</summary>
    {% for entry in remote_address_filters %}
      {% if loop.index > 1 %}
      ,
      {% endif %}
      <a href="/filterinvocations/remote/address/{{ entry["value_hex"] | e }}"><tt>{{ entry["value"] | e }}</tt></a>
    {% endfor %}
  </details>
  {% endif %}
  {% if target_filters %}
  <details>
    <summary>Target</summary>
    {% for entry in target_filters %}
      {% if loop.index > 1 %}
      ,
      {% endif %}
      <a href="/filterinvocations/target/{{ entry["value_hex"] | e }}"><tt>{{ entry["value"] | e }}</tt></a>
    {% endfor %}
  </details>
  {% endif %}
{% endif %}
{% if full_invocations %}
<div id="invocation-list">
<ul>
  {% for invocation in full_invocations %}
  <li> <a href="/invocations/{{invocation.name |e}}"><tt>{{ invocation.name | e }}</tt></a>
    {% if invocation.subcommand %}
    <span id="invocation-verb"><tt>{{ invocation.subcommand | e }}</tt></span>
    {% endif %}
    {% if invocation.target %}
    <span id="invocation-target"><tt>{{ invocation.target | e}}</tt></span>
    {% endif %}
    {% if invocation.build_wall_clock_time %}
    <tt>{{ invocation.build_wall_clock_time | e}}</tt>
    {% endif %}
    {% if invocation.exit_code != 0 %}
    <span id="invocation-failure"><b>
      {% if invocation.exit_code == 1 %}
      build failed
      {% elif invocation.exit_code == 2 %}
      failed
      {% elif invocation.exit_code == 8 %}
      analysis failure
      {% elif invocation.exit_code == 16 %}
      build-environment failure
      {% elif invocation.exit_code == 32 %}
      syntax/invocation error
      {% else %}
      exit code {{ invocation.exit_code | e }}
      {% endif %}
    </b></span>
    {% endif %}
    <ul>
      {% if invocation.remote_address %}
      <li>
        Remote: <tt>{{ invocation.remote_address | e }}@{{ invocation.remote_props | e }}</tt>
      </li>
      {% endif %}
      {% if invocation.config %}
      <li>
        Configuration: <tt>{{ invocation.config | e}}</tt>
      </li>
      {% endif %}
      {% if invocation.context %}
      <li>
        Context: <tt>{{ invocation.context | e }}</tt>
      </li>
      {% endif %}
    </ul>
  </li>
  {% endfor %}
  {% if reduced_invocations %}
  <li>
    <details>
      <summary>{{ reduced_invocations_count | e }} more</summary>
      <ul>
        {% for invocation in reduced_invocations %}
        <li>
          <a href="/invocations/{{invocation.name |e}}"><tt>{{ invocation.name | e }}</tt></a>
          {% if invocation.context %}
          Context: <tt>{{ invocation.context | e }}</tt>
          {% endif %}
        </li>
        {% endfor %}
      </ul>
    </details>
  </li>
  {% endif %}
</ul>
</div>
{% else %}
<i>(none)</i>
{% endif %}
{% endblock %}
