BathHacked/energy-sparks

View on GitHub
app/views/schools/advice/total_energy_use/_analysis.html.erb

Summary

Maintainability
Test Coverage
<p><%= advice_t('total_energy_use.analysis.summary') %></p>

<ul>
  <li><%= link_to(advice_t('total_energy_use.analysis.comparison.title'), '#comparison') %></li>
  <% if @analysis_dates.months_of_data > 23 %>
    <li><%= link_to(advice_t('total_energy_use.analysis.long_term_trend.title'), '#long-term-trend') %></li>
  <% end %>
</ul>

<% if @benchmark_chart.present? %>
  <%= render 'schools/advice/section_title', section_id: 'comparison', section_title: advice_t('total_energy_use.analysis.comparison.title') %>

  <%= component 'chart', chart_type: @benchmark_chart, analysis_controls: false, school: @school do |c| %>
    <% c.with_title { advice_t('total_energy_use.charts.benchmark_one_year.title') } %>
    <% c.with_subtitle do %>
      <%= advice_t('total_energy_use.charts.benchmark_one_year.subtitle', start_date: @analysis_dates.one_year_before_end.to_fs(:es_short), end_date: @analysis_dates.end_date.to_fs(:es_short)) %>
    <% end %>
    <% c.with_footer do %>
      <%= advice_t('total_energy_use.charts.benchmark_one_year.footer') %>
    <% end %>
  <% end %>

  <% if @electricity_annual_usage %>
    <h3><%= t('common.electricity') %></h3>
    <p>
      <%= t('advice_pages.electricity_long_term.analysis.comparison.table_explanation', school_type: t('common.school_types.' + @school.school_type).downcase) %>
    </p>

    <%= render 'schools/advice/electricity_long_term/comparison_with_benchmark_table', annual_usage: @electricity_annual_usage, vs_exemplar: @electricity_vs_exemplar, vs_benchmark: @electricity_vs_benchmark, estimated_savings_vs_exemplar: @electricity_estimated_savings_vs_exemplar, estimated_savings_vs_benchmark: @electricity_estimated_savings_vs_benchmark %>
  <% end %>

  <% if @gas_annual_usage %>
    <h3><%= t('common.gas') %></h3>
    <p>
      <%= t('advice_pages.gas_long_term.analysis.comparison.table_explanation', school_type: t('common.school_types.' + @school.school_type).downcase) %>
    </p>

    <%= render 'schools/advice/gas_long_term/comparison_with_benchmark_table', annual_usage: @gas_annual_usage, vs_exemplar: @gas_vs_exemplar, vs_benchmark: @gas_vs_benchmark, estimated_savings_vs_exemplar: @gas_estimated_savings_vs_exemplar, estimated_savings_vs_benchmark: @gas_estimated_savings_vs_benchmark %>
  <% end %>

<% end %>

<% if @analysis_dates.months_of_data > 23 %>
  <%= render 'schools/advice/section_title', section_id: 'long-term-trend', section_title: advice_t('total_energy_use.analysis.long_term_trend.title') %>

  <%= component 'chart', chart_type: :stacked_all_years, school: @school do |c| %>
    <% c.with_title { advice_t('total_energy_use.charts.stacked_all_years.title') } %>
    <% c.with_subtitle do %>
      <%= advice_t('total_energy_use.charts.stacked_all_years.subtitle') %>
    <% end %>
  <% end %>
<% end %>