BathHacked/energy-sparks

View on GitHub
app/views/admin/reports/tariff_import_logs/index.html.erb

Summary

Maintainability
Test Coverage
<h1>Tariff Import Logs</h1>

<% if @errored_logs.any? %>
<h2>Errored</h2>
<table class="table table-striped">
  <thead>
    <tr>
      <th>Source</th>
      <th>Description</th>
      <th>Error messages</th>
      <th>Import Time</th>
    </tr>
  </thead>
  <tbody>
    <% @errored_logs.each do |log| %>
      <tr>
        <td class="nowrap"><%= log.source %></td>
        <td><%= log.description %></td>
        <td><%= log.error_messages %></td>
        <td class="nowrap"><%= nice_date_times log.import_time %></td>
      </tr>
    <% end %>
  </tbody>
</table>
<% else %>
  <p>There are no import logs with errors</p>
<% end %>

<h2>Successful</h2>
<%= render partial: 'shared/pagy/bootstrap_nav', locals: { pagy: @pagy } %>
<table class="table table-striped">
  <thead>
    <tr>
      <th>Source</th>
      <th>Description</th>
      <th>Import Time</th>
      <th>Prices imported</th>
      <th>Prices updated</th>
      <th>Standing charges imported</th>
      <th>Standing charges updated</th>
    </tr>
  </thead>
  <tbody>
    <% @successful_logs.each do |log| %>
      <tr>
        <td class="nowrap"><%= log.source %></td>
        <td><%= log.description %></td>
        <td class="nowrap"><%= nice_date_times log.import_time %></td>
        <td><%= log.prices_imported %></td>
        <td><%= log.prices_updated %></td>
        <td><%= log.standing_charges_imported %></td>
        <td><%= log.standing_charges_updated %></td>
      </tr>
    <% end %>
  </tbody>
</table>