BathHacked/energy-sparks

View on GitHub
app/views/schools/advice/long_term/_current_usage.html.erb

Summary

Maintainability
Test Coverage
<%= render 'schools/advice/section_title',
           section_id: 'current',
           section_title: t("advice_pages.#{fuel_type}_long_term.insights.current_usage.title") %>

<%= component 'alerts', school: school, dashboard_alerts: dashboard_alerts,
                        alert_types: alert_types_for_class(alert_class), show_links: false, show_icons: false %>

<table class="table table-sm advice-table">
  <thead class="thead-dark">
    <th><%= t('advice_pages.tables.columns.period') %></th>
    <th class="text-right"><%= t('advice_pages.electricity_long_term.tables.columns.usage_kwh') %></th>
    <th class="text-right"><%= t('advice_pages.electricity_long_term.tables.columns.usage_co2') %></th>
    <th class="text-right"><%= t('advice_pages.electricity_long_term.tables.columns.usage_gbp') %></th>
    <th class="text-right"><%= t('advice_pages.electricity_long_term.tables.columns.annual_change') %></th>
  </thead>
  <tbody>
    <tr>
      <td>
        <% if analysis_dates.one_years_data? %>
          <%= t('advice_pages.electricity_long_term.insights.current_usage.last_year') %>
        <% else %>
          <%= format_date_range([analysis_dates.start_date, analysis_dates.end_date]) %>
        <% end %>
      </td>
      <td class="text-right"><%= format_unit(annual_usage.kwh, :kwh) %></td>
      <td class="text-right"><%= format_unit(annual_usage.co2, :co2) %></td>
      <td class="text-right"><%= format_unit(annual_usage.£, :£) %></td>
      <td class="text-right">
        <% if annual_usage_change_since_last_year.present? %>
          <%= up_downify(format_unit(annual_usage_change_since_last_year.percent, :relative_percent, false),
                         sanitize: false) %>
        <% else %>
          -
        <% end %>
      </td>
    </tr>
  </tbody>
</table>
<%= render 'schools/advice/how_have_we_analysed_your_data_table_caption',
           data_target: 'how-have-we-analysed-your-data-footnotes' %>
<p><a href="<%= polymorphic_path([:analysis_school_advice, fuel_type, :long_term]) %>">
<%= t('advice_pages.electricity_long_term.insights.current_usage.review_our_analysis') %></a></p>