BathHacked/energy-sparks

View on GitHub
app/views/home/_country_summary.html.erb

Summary

Maintainability
Test Coverage
<div class="row">
  <div class="col">
    <h2><%= t('school_statistics.by_country') %></h2>

    <table class="table table-bordered table-sm">
      <thead>
        <tr>
          <th><%= t('school_statistics.country') %></th>
          <th class="text-right"><%= t('school_statistics.count') %></th>
          <th class="text-right"><%= t('school_statistics.pupil_numbers') %></th>
        </tr>
      </thead>
      <tbody>
        <% report.country_summary.each do |row| %>
          <tr>
            <% country = School.countries.key(row['country']) %>
            <td><%= I18n.t("school_statistics.#{country}") %></td>
            <td class="text-right"><%= row['school_count'] %></td>
            <td class="text-right"><%= row['pupil_count'] %></td>
          </tr>
        <% end %>
        <tr>
          <td><strong><%= t('school_statistics.total') %></strong></td>
          <td class="text-right"><%= School.visible.count %></td>
          <td class="text-right"><%= School.visible.sum(:number_of_pupils) %></td>
        </tr>
      </tbody>
    </table>
  </div>
</div>