{% include "obsfx_table_text" %}
{% import "macros.j2" as macros with context %}
<table class="table table-striped table-borderless obsfx-table" style="width:100%; ">
  <caption style="caption-side: top; text-align: center;">
    Table of data alignment parameters
  </caption>
  <colgroup>
    <col style="width: 16%">
    <col style="width: 9%">
    <col style="width: 16%">
    <col style="width: 9%">
    <col style="width: 16%">
    <col style="width: 9%">
    <col style="width: 16%">
    <col style="width: 9%">
  </colgroup>
  <thead style="text-align: left;">
    <tr class="header" style="text-align: center;">
      <th colspan="2">Aligned Pairs</th>
      <th colspan="2">Observations</th>
      <th colspan="2">Forecasts</th>
      <th colspan="2">Reference Forecasts</th>
    </tr>
    <tr>
      <th>Name</th>
      <th>Interval Label<br>Interval Length</th>
      <th>Name</th>
      <th>Interval Label<br>Interval Length</th>
      <th>Name</th>
      <th>Interval Label<br>Interval Length</th>
      <th>Name</th>
      <th>Interval Label<br>Interval Length</th>
    </tr>
  </thead>
  <tbody style="text-align: left; overflow-wrap: break-word;">
    {% for pfxobs in report.raw_report.processed_forecasts_observations %}
    <tr>
      <td>{{pfxobs.name}}</td>
      <td>
        {{ pfxobs.interval_label }}
        <br>
        {{ (pfxobs.interval_length.total_seconds() // 60) | int }} min
      </td>
      <td>
        {% if pfxobs.original.observation is defined %}
        <a href="{{ dash_url }}/observations/{{ pfxobs.original.observation.observation_id }}">
          {{ pfxobs.original.observation.name }}
        </a>
        {% else %}
        <a href="{{ dash_url }}/aggregates/{{ pfxobs.original.aggregate.aggregate_id }}">
          {{ pfxobs.original.aggregate.name }}
        </a>
        {% endif %}
      </td>
      <td>
        {{ pfxobs.original.data_object.interval_label }}
        <br>
        {{ (pfxobs.original.data_object.interval_length.total_seconds() // 60) | int }} min
      </td>
      <td>
        <a href="{{ dash_url }}/{{ macros.forecast_route(pfxobs.original.forecast) }}">
          {{ pfxobs.original.forecast.name }}
         </a>
      </td>
      <td>
        {{ pfxobs.original.forecast.interval_label }}
        <br>
        {{ (pfxobs.original.forecast.interval_length.total_seconds() // 60) | int }} min
      </td>
      <td>
        {% if pfxobs.original.reference_forecast != none %}
        <a href="{{ dash_url }}/{{ macros.forecast_route(pfxobs.original.reference_forecast.forecast_id) }}">
          {{ pfxobs.original.reference_forecast.name if pfxobs.original.reference_forecast != none else 'None' }}
        </a>
        {% else %}
          None
        {% endif %}
      </td>
      <td>
        {{ pfxobs.original.reference_forecast.interval_label if pfxobs.original.reference_forecast != none }}
        <br>
        {% if pfxobs.original.reference_forecast != none %}
          {{ (pfxobs.original.reference_forecast.interval_length.total_seconds() // 60) | int }} min
        {% endif %}
      </td>
    </tr>
    {% endfor %}
  </tbody>
</table>
