BathHacked/energy-sparks

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

Summary

Maintainability
Test Coverage
<p><%= t('advice_pages.gas_recent_changes.analysis.summary') %></p>

<p><%= t('advice_pages.gas_recent_changes.analysis.sections') %></p>

<ul>
  <li><%= link_to(t('advice_pages.gas_recent_changes.analysis.compare_recent_weeks.title'), '#compare-recent-weeks') %></li>
  <li><%= link_to(t('advice_pages.gas_recent_changes.analysis.compare_recent_days.title'), '#compare-recent-days') %></li>
  <li><%= link_to(t('advice_pages.gas_recent_changes.analysis.compare_last_week.title'), '#compare-last-week') %></li>
  <li><%= link_to(t('advice_pages.gas_recent_changes.analysis.impact_of_temperature.title'), '#impact-of-temperature') %></li>
</ul>

<!--  COMPARISON OF GAS USE OVER 2 RECENT WEEKS -->
<%= render 'schools/advice/section_title', section_id: 'compare-recent-weeks',
                                           section_title: t('advice_pages.gas_recent_changes.analysis.compare_recent_weeks.title') %>
<div class="charts">
  <%= component 'chart',
                chart_type: :calendar_picker_gas_week_example_comparison_chart,
                school: @school,
                analysis_controls: false,
                no_zoom: true,
                chart_config: @chart_config,
                html_class: 'usage-chart' do |c| %>
    <% c.with_title { t('advice_pages.gas_recent_changes.analysis.charts.compare_recent_weeks_chart_title') } %>
    <% c.with_subtitle { t('advice_pages.gas_recent_changes.analysis.charts.compare_recent_weeks_chart_subtitle') } %>
    <% c.with_header do %>
      <p><%= t('advice_pages.gas_recent_changes.analysis.charts.compare_recent_weeks_chart_explanation') %></p>
    <% end %>
    <% c.with_footer do %>
      <%= render 'shared/usage_controls', chart_config: @chart_config, period: :weekly, supply: :gas,
                                          split_meters: true, meters: @meters %>
    <% end %>
  <% end %>
</div>

<!--  COMPARISON OF GAS USE OVER 2 RECENT DAYS -->
<%= render 'schools/advice/section_title', section_id: 'compare-recent-days',
                                           section_title: t('advice_pages.gas_recent_changes.analysis.compare_recent_days.title') %>

<div class="charts">
  <%= component 'chart',
                chart_type: :calendar_picker_gas_day_example_comparison_chart,
                school: @school,
                analysis_controls: false,
                no_zoom: true,
                chart_config: @chart_config,
                axis_controls: false,
                html_class: 'usage-chart' do |c| %>
    <% c.with_title { t('advice_pages.gas_recent_changes.analysis.charts.compare_recent_days_chart_title') } %>
    <% c.with_subtitle { t('advice_pages.gas_recent_changes.analysis.charts.compare_recent_days_chart_subtitle') } %>
    <% c.with_header do %>
      <p><%= t('advice_pages.gas_recent_changes.analysis.charts.compare_recent_days_chart_explanation') %></p>
    <% end %>
    <% c.with_footer do %>
      <%= render 'shared/usage_controls', chart_config: @chart_config, period: :daily, supply: :gas,
                                          split_meters: true, meters: @meters %>
      <br>
      <p><%= t('advice_pages.gas_recent_changes.analysis.expected_usage_patterns') %></p>
      <p><%= t('advice_pages.gas_recent_changes.analysis.optimal_start_control') %></p>
    <% end %>
  <% end %>
</div>

<%= render 'schools/advice/section_title', section_id: 'compare-last-week',
                                           section_title: t('advice_pages.gas_recent_changes.analysis.compare_last_week.title') %>

<%= component 'alerts', school: @school,
                        dashboard_alerts: @dashboard_alerts,
                        alert_types: alert_types_for_class([AlertSchoolWeekComparisonGas, AlertWeekendGasConsumptionShortTerm]),
                        show_links: false, show_icons: false %>

<%= component 'chart',
              chart_type: :last_7_days_intraday_gas,
              school: @school,
              analysis_controls: true,
              no_zoom: true,
              axis_controls: false do |c| %>
  <% c.with_title { t('advice_pages.gas_recent_changes.analysis.charts.compare_last_week_chart_title') } %>
  <% c.with_subtitle { t('advice_pages.gas_recent_changes.analysis.charts.compare_last_week_chart_subtitle') } %>
  <% c.with_header do %>
    <p><%= t('advice_pages.gas_recent_changes.analysis.charts.compare_last_week_chart_explanation') %></p>
  <% end %>
  <% c.with_footer do %>
    <p><%= t('advice_pages.gas_recent_changes.analysis.charts.compare_last_week_chart_footer') %></p>
  <% end %>
<% end %>

<!--  IMPACT ON GAS USE OF TEMP -->
<%= render 'schools/advice/section_title', section_id: 'impact-of-temperature',
                                           section_title: t('advice_pages.gas_recent_changes.analysis.impact_of_temperature.title') %>

<%= component 'chart',
              chart_type: :last_2_weeks_gas_degreedays,
              school: @school,
              analysis_controls: true,
              no_zoom: true,
              chart_config: @chart_config,
              axis_controls: false do |c| %>
  <% c.with_title { t('advice_pages.gas_recent_changes.analysis.charts.impact_of_temperature_chart_title') } %>
  <% c.with_subtitle do
       t('advice_pages.gas_recent_changes.analysis.charts.impact_of_temperature_chart_subtitle_html',
         start_date: short_dates(@chart_config[:last_reading] - 13.days), end_date: short_dates(@chart_config[:last_reading]))
     end %>
  <% c.with_footer do %>
    <% more_detail_url = link_to(t('advice_pages.gas_recent_changes.analysis.see_more_detail'),
                                 'https://www.sustainabilityexchange.ac.uk/files/degree_days_for_energy_management_carbon_trust.pdf', target: '_blank', rel: 'noopener') %>
    <p><%= t('advice_pages.gas_recent_changes.analysis.charts.impact_of_temperature_chart_explanation_html', more_detail_url:) %></p>
  <% end %>
<% end %>