{% extends 'base.j2' %}
{% block title %}task{% endblock %}
{% block content %}
<h1>task</h1>

<table>
<thead>
    <tr>
        <th>key</th>
        <th>value</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>id</td>
        <td>{{ task.id }}</td>
    </tr>
    <tr>
        <td>dag_id</td>
        <td><a href="/dags/{{ task.dag_id }}"><code>{{ task.dag_id }}</code></a></td>
    </tr>
    <tr>
        <td>task_type</td>
        <td>{{ task.task_type }}</td>
    <tr>
        <td>status</td>
        <td><code>{{ task.status }}</code></td>
    </tr>
    <tr>
        <td>created_at</td>
        <td><code>{{ task.created_at|format_time if task.created_at is not none else 'NULL'}}</code></td>
    </tr>
    <tr>
        <td>updated_at</td>
        <td><code>{{ task.updated_at|format_time if task.updated_at is not none else 'NULL'}}</code></td>
    </tr>
    <tr>
        <td>started_at</td>
        <td><code>{{ task.started_at|format_time if task.started_at is not none else 'NULL'}}</code></td>
    </tr>
    <tr>
        <td>stopped_at</td>
        <td><code>{{ task.stopped_at|format_time if task.stopped_at is not none else 'NULL'}}</code></td>
    </tr>
    <tr>
        <td>duration</td>
        <td><code>{{ task.duration_seconds|round(1) if task.duration_seconds is not none else 'NULL' }}</code></td>
    </tr>
    <tr>
        <td>logs</td>
        <td><a href="/logs/{{ task.id }}.txt">logs</code></a></td>
    </tr>
    <tr>
        <td>worker</td>
        <td><a href="/workers/{{ task.worker_id }}">{{ task.worker_name }}</a></td>
    </tr>
</tbody>
</table>


<a href="/tasks/{{ task.id }}/input_data.json"><h2>input_data.json</h2></a>
{% if task.input_data %}
<table>
<thead>
    <tr>
        <th>key</th>
        <th>value</th>
    </tr>
</thead>
<tbody>
    {% for key, value in task.input_data.items() %}
    <tr>
        <td>{{ key }}</td>
        <td><code>{{ value }}</code></td>
    </tr>
    {% endfor %}
</tbody>
</table>
{% else %}
<p>no input data</p>
{% endif %}


<a href="/tasks/{{ task.id }}/output_data.json"><h2>output_data.json</h2></a>
{% if task.output_data %}
<table>
<thead>
    <tr>
        <th>key</th>
        <th>value</th>
    </tr>
</thead>
<tbody>
    {% for key, value in task.output_data.items() %}
    <tr>
        <td>{{ key }}</td>
        <td><code>{{ value }}</code></td>
    </tr>
    {% endfor %}
</tbody>
</table>
{% else %}
<p>no output data</p>
{% endif %}

<h2>upstream tasks (dependencies)</h2>
<table>
<thead>
    <tr>
        <th>task_id</th>
    </tr>
</thead>
<tbody>
    {% for task_id in task.upstream %}
    <tr>
        <td><a href="/tasks/{{ task_id }}"><code>{{ task_id }}</code></a></td>
    </tr>
    {% endfor %}
</tbody>
</table>


<h2>downstream tasks</h2>
<table>
<thead>
    <tr>
        <th>task_id</th>
    </tr>
</thead>
<tbody>
    {% for task_id in task.downstream %}
    <tr>
        <td><a href="/tasks/{{ task_id }}"><code>{{ task_id }}</code></a></td>
    </tr>
    {% endfor %}
</tbody>
</table>

{% endblock %}
