From 0c8870f8f627fa67fd98853a522f1fc9c8496bb8 Mon Sep 17 00:00:00 2001 From: martintomas Date: Wed, 23 Oct 2024 13:38:37 +0200 Subject: [PATCH 1/5] refactoring: Removing BETA naming --- app/assets/stylesheets/tpi/pages/company.scss | 4 ---- app/controllers/concerns/tpi/user_download.rb | 6 ++---- app/controllers/tpi/companies_controller.rb | 1 + app/controllers/tpi/sectors_controller.rb | 1 + app/controllers/tpi/tpi_controller.rb | 4 ++++ .../components/tpi/charts/mq-level/options.js | 5 +---- app/models/mq/assessment.rb | 2 +- .../tpi/companies/_mq_assessment.html.erb | 2 +- app/views/tpi/companies/show.html.erb | 5 ----- app/views/tpi/sectors/index.html.erb | 5 ----- app/views/tpi/sectors/show.html.erb | 5 ----- .../tpi/sectors_controller_spec.rb | 16 +++++++-------- spec/support/capybara_helpers.rb | 9 +++------ spec/system/public/tpi/company_spec.rb | 10 +++++----- spec/system/public/tpi/sectors_spec.rb | 20 +++++++++---------- 15 files changed, 37 insertions(+), 58 deletions(-) diff --git a/app/assets/stylesheets/tpi/pages/company.scss b/app/assets/stylesheets/tpi/pages/company.scss index b985cf308..b5615106f 100644 --- a/app/assets/stylesheets/tpi/pages/company.scss +++ b/app/assets/stylesheets/tpi/pages/company.scss @@ -243,10 +243,6 @@ border-left: 2px solid $hawkes-blue; - &.level5 { - background-color: rgba($tpi-level5-background-color, 0.15); - } - &__header { font-size: 16px; font-weight: bold; diff --git a/app/controllers/concerns/tpi/user_download.rb b/app/controllers/concerns/tpi/user_download.rb index 72bfb1089..8fb908145 100644 --- a/app/controllers/concerns/tpi/user_download.rb +++ b/app/controllers/concerns/tpi/user_download.rb @@ -12,10 +12,8 @@ def send_tpi_user_file(mq_assessments:, cp_assessments:, filename:) .includes(sector: [:cp_units]) mq_assessments_files = mq_assessments_by_methodology.map do |methodology, assessments| - is_beta_methodology = MQ::Assessment::BETA_METHODOLOGIES.include? methodology - name = is_beta_methodology ? "#{methodology}_BETA_#{timestamp}" : "#{methodology}_#{timestamp}" { - "MQ_Assessments_Methodology_#{name}.csv" => CSVExport::User::MQAssessments.new(assessments).call + "MQ_Assessments_Methodology_#{methodology}_#{timestamp}.csv" => CSVExport::User::MQAssessments.new(assessments).call } end.reduce(&:merge) @@ -38,7 +36,7 @@ def send_tpi_user_file(mq_assessments:, cp_assessments:, filename:) 'User guide TPI files.xlsx' => user_guide ) if ENV['MQ_BETA_ENABLED'].to_s == 'true' - files = files.merge 'Company_Latest_Assessments_BETA_5.0.csv' => latest_cp_assessments_beta_csv + files = files.merge 'Company_Latest_Assessments_5.0.csv' => latest_cp_assessments_beta_csv end render zip: files.compact, filename: "#{filename} - #{timestamp}" end diff --git a/app/controllers/tpi/companies_controller.rb b/app/controllers/tpi/companies_controller.rb index d2724d22b..0d6b53856 100644 --- a/app/controllers/tpi/companies_controller.rb +++ b/app/controllers/tpi/companies_controller.rb @@ -2,6 +2,7 @@ module TPI class CompaniesController < TPIController include UserDownload + before_action :enable_beta_mq_assessments before_action :fetch_company before_action :redirect_if_numeric_or_historic_slug, only: [:show] before_action :fetch_cp_assessment, only: [:show, :cp_assessment, :emissions_chart_data] diff --git a/app/controllers/tpi/sectors_controller.rb b/app/controllers/tpi/sectors_controller.rb index 2e6cd22c5..e27d3cd6d 100644 --- a/app/controllers/tpi/sectors_controller.rb +++ b/app/controllers/tpi/sectors_controller.rb @@ -2,6 +2,7 @@ module TPI class SectorsController < TPIController include UserDownload + before_action :enable_beta_mq_assessments before_action :fetch_companies, only: [:show, :index] before_action :fetch_sectors, only: [:show, :index, :user_download_all] before_action :fetch_sector, only: [:show, :user_download] diff --git a/app/controllers/tpi/tpi_controller.rb b/app/controllers/tpi/tpi_controller.rb index c0893c6ec..d4add55b1 100644 --- a/app/controllers/tpi/tpi_controller.rb +++ b/app/controllers/tpi/tpi_controller.rb @@ -6,6 +6,10 @@ class TPIController < ApplicationController protected + def enable_beta_mq_assessments + session[:enable_beta_mq_assessments] = true unless session.key?(:enable_beta_mq_assessments) + end + def fixed_navbar(admin_panel_section_title, admin_panel_link) @admin_panel_section_title = admin_panel_section_title @link = admin_panel_link diff --git a/app/javascript/components/tpi/charts/mq-level/options.js b/app/javascript/components/tpi/charts/mq-level/options.js index a76a505dd..ea28b5fb6 100644 --- a/app/javascript/components/tpi/charts/mq-level/options.js +++ b/app/javascript/components/tpi/charts/mq-level/options.js @@ -58,10 +58,7 @@ export function getOptions({ chartData }) { fontSize: '12px' }, useHTML: true, - stagger: 0, - formatter() { - return this.value === 5 ? '5 [BETA]' : this.value; - } + stagger: 0 }, title: { text: 'Level', diff --git a/app/models/mq/assessment.rb b/app/models/mq/assessment.rb index 2e3b46082..291ddd2aa 100644 --- a/app/models/mq/assessment.rb +++ b/app/models/mq/assessment.rb @@ -22,7 +22,7 @@ class Assessment < ApplicationRecord LEVELS = %w[0 1 2 3 4 4STAR 5 5STAR].freeze BETA_METHODOLOGIES = { # taken into account only when beta is enabled - 5 => {levels: %w[5], highlight_questions: %w[18]} + 5 => {levels: %w[5], highlight_questions: %w[]} }.freeze BETA_LEVELS = BETA_METHODOLOGIES.map { |_k, v| v[:levels] }.flatten.freeze diff --git a/app/views/tpi/companies/_mq_assessment.html.erb b/app/views/tpi/companies/_mq_assessment.html.erb index 11ef814f4..b0855b95a 100644 --- a/app/views/tpi/companies/_mq_assessment.html.erb +++ b/app/views/tpi/companies/_mq_assessment.html.erb @@ -31,7 +31,7 @@ <% assessment.questions_by_level.each do |level, questions| %>

- Level <%= level.in?(assessment.beta_levels) ? "#{level} [BETA]" : level %>: <%= t("tpi.company.level_description.#{level}") %> + Level <%= "#{level}: #{t("tpi.company.level_description.#{level}")}" %>

diff --git a/app/views/tpi/companies/show.html.erb b/app/views/tpi/companies/show.html.erb index 88b4e7a9b..230f83ef8 100644 --- a/app/views/tpi/companies/show.html.erb +++ b/app/views/tpi/companies/show.html.erb @@ -1,11 +1,6 @@ <% content_for :page_title, "#{@company.name} - Transition Pathway Initiative" %> <% content_for :page_description, "Assess how prepared #{@company.name} is for the transition to a low-carbon economy – its Management Quality and Carbon Performance." %> -<%= react_component('MqBetaModal', { - enabled: session[:enable_beta_mq_assessments], - page: "companies" -}) %> - <% regional_view = @company.cp_alignment_region.present? && params[:view] == 'regional' %>
diff --git a/app/views/tpi/sectors/index.html.erb b/app/views/tpi/sectors/index.html.erb index 1fb91630f..c3e9eb330 100644 --- a/app/views/tpi/sectors/index.html.erb +++ b/app/views/tpi/sectors/index.html.erb @@ -1,11 +1,6 @@ <% content_for :page_title, "Tool - Transition Pathway Initiative" %> <% content_for :page_description, "The TPI tool is a corporate climate action benchmark which assesses how prepared companies are for the transition to a low-carbon economy." %> -<%= react_component('MqBetaModal', { - enabled: session[:enable_beta_mq_assessments], - page: "company" -}) %> -