BathHacked/energy-sparks

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

Summary

Maintainability
Test Coverage
<%= component 'notice', status: :neutral do |c| %>
  <%= t('advice_pages.hot_water.analysis.summary_notice') %>
<% end %>
<br>
<%= t('advice_pages.hot_water.analysis.introduction_html') %>

<ul>
  <li>
    <a href='#hot_water_efficiency_improvement_options'>
      <%= t('advice_pages.hot_water.analysis.hot_water_efficiency_improvement_options') %>
    </a>
  </li>
  <li>
    <a href='#how_does_energy_sparks_calculate'>
      <%= t('advice_pages.hot_water.analysis.how_does_energy_sparks_calculate') %>
    </a>
  </li>
</ul>

<%= render 'schools/advice/section_title', section_id: 'hot_water_efficiency_improvement_options', section_title: t('advice_pages.hot_water.analysis.hot_water_efficiency_improvement_options') %>

<%= component 'notice', status: :neutral do |c| %>
  <%= t('advice_pages.hot_water.analysis.hot_water_efficiency_improvement_options_notice_html') %>
<% end %>
<br />
<%= t('advice_pages.hot_water.analysis.hot_water_efficiency_improvement_options_content_html') %>

<%= render 'analysis_table' %>

<%= t('advice_pages.hot_water.analysis.hot_water_efficiency_improvement_options_table_footer_html') %>

<% if @gas_hot_water.investment_choices.point_of_use_electric.saving_£ > @gas_hot_water.investment_choices.gas_better_control.saving_£ &&
     @gas_hot_water.investment_choices.point_of_use_electric.saving_co2 > @gas_hot_water.investment_choices.gas_better_control.saving_co2 %>
     <p>
       <%= t('advice_pages.hot_water.analysis.options.point_of_use_best') %>
     </p>
<% elsif @gas_hot_water.investment_choices.point_of_use_electric.saving_£ < @gas_hot_water.investment_choices.gas_better_control.saving_£ &&
     @gas_hot_water.investment_choices.point_of_use_electric.annual_£ > @gas_hot_water.investment_choices.existing_gas.annual_£ &&
     @gas_hot_water.investment_choices.point_of_use_electric.saving_co2 > @gas_hot_water.investment_choices.gas_better_control.saving_co2 %>
     <p>
       <%= t('advice_pages.hot_water.analysis.options.point_of_use_co2_saving') %>
     </p>
<% elsif @gas_hot_water.investment_choices.point_of_use_electric.saving_£ < @gas_hot_water.investment_choices.gas_better_control.saving_£ &&
  @gas_hot_water.investment_choices.point_of_use_electric.annual_£ < @gas_hot_water.investment_choices.existing_gas.annual_£ &&
  @gas_hot_water.investment_choices.point_of_use_electric.saving_co2 > @gas_hot_water.investment_choices.gas_better_control.saving_co2 %>
    <p>
       <%= t('advice_pages.hot_water.analysis.options.point_of_use_larger_co2_benefit') %>
    </p>
<% elsif @gas_hot_water.investment_choices.point_of_use_electric.saving_£ < @gas_hot_water.investment_choices.gas_better_control.saving_£ &&
  @gas_hot_water.investment_choices.point_of_use_electric.saving_co2 < @gas_hot_water.investment_choices.gas_better_control.saving_co2 %>
    <p>
       <%= t('advice_pages.hot_water.analysis.options.point_of_use_not_worthwhile') %>
    </p>
<% end %>

<p><strong><%= t('advice_pages.hot_water.analysis.improved_boiler_control_title') %></strong></p>
<%= t('advice_pages.hot_water.analysis.improved_boiler_control_content_html',
      gas_better_control_saving_gbp: format_unit(@gas_hot_water.investment_choices.gas_better_control.saving_£, :£),
      gas_better_control_saving_co2: format_unit(@gas_hot_water.investment_choices.gas_better_control.saving_co2, :co2),
      gas_better_control_saving_co2_percent: format_unit(@gas_hot_water.investment_choices.gas_better_control.saving_co2_percent, :percent)
  )
%>

<p><strong><%= t('advice_pages.hot_water.analysis.point_of_use_electric_heater_title') %></strong></p>
<%= t('advice_pages.hot_water.analysis.point_of_use_electric_heater_content_html',
       point_of_use_electric_saving_gbp: format_unit(@gas_hot_water.investment_choices.point_of_use_electric.saving_£, :£),
       point_of_use_electric_saving_co2: format_unit(@gas_hot_water.investment_choices.point_of_use_electric.saving_co2, :co2),
       point_of_use_electric_saving_co2_percent: format_unit(@gas_hot_water.investment_choices.point_of_use_electric.saving_co2_percent, :percent)
  )
%>

<%= render 'schools/advice/section_title', section_id: 'how_does_energy_sparks_calculate', section_title: t('advice_pages.hot_water.analysis.how_does_energy_sparks_calculate') %>
<%= t('advice_pages.hot_water.analysis.how_does_energy_sparks_calculate_content_introduction_html') %>

<%= component 'chart', chart_type: :hotwater, analysis_controls: false, school: @school do |c| %>
<% end %>

<% annual_litres = AnalyseHeatingAndHotWater::HotwaterModel.annual_school_hot_water_litres(@school.number_of_pupils) %>
<% annual_kwh = AnalyseHeatingAndHotWater::HotwaterModel.heat_capacity_water_kwh(annual_litres) %>


<%= t('advice_pages.hot_water.analysis.theoretically_every_pupil_uses_html',
       number_of_pupils: @school.number_of_pupils,
       theoretical_annual_hot_water_requirement_litres: format_unit(annual_litres, :litre),
       theoretical_annual_hot_water_requirement_kwh: format_unit(annual_kwh, :kwh)
  )
%>
<%= t('advice_pages.hot_water.analysis.we_calculate_the_efficiency_html',
       theoretical_annual_hot_water_requirement_kwh: format_unit(annual_kwh, :kwh),
       existing_gas_annual_kwh: format_unit(@gas_hot_water.efficiency_breakdowns.daily.kwh.total, :kwh)
  )
%>
<%= t('advice_pages.hot_water.analysis.the_circulatory_gas_based_systems_html',
  existing_gas_efficiency: format_unit(@gas_hot_water.investment_choices.existing_gas.efficiency, :percent)
  )
%>