<h5 style="margin-top: 40px; text-align: center;">Результаты поиска документа</h5>
{% import "macro.html" as macro %}
{% if 'backends' in response %}
{% set backends = response['backends'] %}
    <br> <font color="green">{{ 'Url:' }}</font> <font color="blue">{{ backends['Url'] }}</font>
<br> <font color="green">{{ 'Kps:' }}</font> {{ backends['Kps'] }}
<br><br> <font color="green">{{ 'RtyServer' }}</font>
{% if response['backends']["RtyServer"]["Shard range"] == (-1, -1) %}
    <br> <font color="green">{{ 'Shard Range: ' }}</font> {{ 'NO' }}
    <br><br><font color="red">{{ "Document not Found" }}</font>
    {% else %}
    <br> <font color="green">{{ 'Shard Range: ' }}</font> {{ backends['RtyServer']['Shard range'] }}
    {% endif %}
{% set color_by_document_hash = {} %}
{% macro output_host(host_data) %}
    <tr>
        <td>{{ host_data.hostname }}</td>
    {% if host_data.document %}
        <td><font color="blue">{{ host_data.document_hash }}</font></td>
    {% elif host_data.error %}
        <td><font color="red">{{ "Error:" + host_data.error }}</font></td>
    {% else %}
        <td><font color="red">{{ 'Not Found' }}</font></td>
    {% endif %}
    </tr>
{% endmacro %}
{% if 'Shard range' in backends["RtyServer"] and backends["RtyServer"]["Shard range"] != (-1, -1) %}
    <br><br><font color="green">{{ "Backends" }}</font><br>
    <table border="1" width="100%" cellpadding="5">
    {% for host_data in backends['RtyServer']['Backends'] %}
    {{ output_host(host_data) }}
    {% endfor %}
    </table>
{% if 'Other errors' in backends["RtyServer"] %}
    <br><br><font color="red">{{ "Other errors" }}</font><br>
    <table border="1" width="100%" cellpadding="5">
    {% for host_data in backends["RtyServer"]['Other errors'] %}
    {{ output_host(host_data) }}
    {% endfor %}
    </table>
{% endif %}
    {% elif 'Errors' in backends["RtyServer"] %}
    <table border="1" width="100%" cellpadding="5">
        <br><br><font color="red">{{ 'Errors' }}</font><br>
    {% for host_data in backends["RtyServer"]['Errors'] %}
    {{ output_host(host_data) }}
    {% endfor %}
    </table>
{% endif %}
{% endif %}
{% if 'ferryman' in response %}
{% set flag = False %}
{% for host in response['ferryman']["Ferryman hosts"] %}
{%  if host in response['ferryman']['Ferryman urls exception'] and not flag %}
    <br><font color="blue">{{ response['ferryman']["Ferryman urls"][host] }}</font>
    {% set flag = True %}
{% endif %}
{% endfor %}
<br><br><font color="green">{{ "Ferryman" }}</font>
<br><font color="green">{{ " Shard index: " + response['ferryman']["Ferryman"]["Shard index"] }}</font>
{% macro output_ferryman_table(fields) %}
{% set ca = fields['action'] %}
<tr>
<td>{{ fields['table_mtime'] }}</td>
<td>{{ fields['table_path']+fields['path_padding'] }}</td>
<td>{{ fields['doc_mtime'] }}</td>
<td>{{ ca }}</td>
<td>{{ fields['deadline'] }}</td>
</tr>
{% endmacro %}
<br><font color="green">{{ "Tables" }}</font><br>
{% for table_group_name, table_group_title in response['ferryman']["Ferryman"]["Tables"]['Table_map'] %}
    <br><font color="#BE33FF">{{ table_group_title }}</font>
{% set longest_table_path = response['ferryman']["Ferryman"]["Tables"][table_group_name]['longest_table_path'] %}
{% set common_prefix = response['ferryman']["Ferryman"]["Tables"][table_group_name]['common_prefix'] %}
<table border="1" width="100%" cellpadding="5">
<tr>
    <th>{{ 'table_mtime'.ljust(19) }}</th><th>{{ 'table_path'.ljust(
        longest_table_path - common_prefix|length) }}</th><th>{{ 'doc_mtime' }}</th><th>{{ 'action' }}</th><th>{{ 'deadline' }}</th>
</tr>
{% for el in response['ferryman']["Ferryman"]["Tables"][table_group_name]['Documents'] %}
    {{ output_ferryman_table(el) }}
    {% endfor %}
</table>
{% endfor %}
{% endif %}
{% if 'yql' in response %}
<br><a href="{{ response['yql']['docfetcher'] }}">Docfetcher logs</a>
<br><a href="{{ response['yql']['index'] }}">Indexerproxy logs</a>
{% endif %}
