diff --git a/app/assets/stylesheets/tpi/_publications.scss b/app/assets/stylesheets/tpi/_publications.scss index e303d03f2..4219b9b79 100644 --- a/app/assets/stylesheets/tpi/_publications.scss +++ b/app/assets/stylesheets/tpi/_publications.scss @@ -259,10 +259,10 @@ $max-lines: 3; } &__content-type { - color: $grey-dark; - margin-top: 10px; + color: $blue; + margin: 0 0 10px 0; font-size: $size-7; - border: 1px solid rgba($grey-dark, 0.5); + border: 1px solid rgba($blue, 0.5); padding-left: $size-7; padding-right: $size-7; display: inline-block; diff --git a/app/controllers/tpi/sectors_controller.rb b/app/controllers/tpi/sectors_controller.rb index c9447407b..2e6cd22c5 100644 --- a/app/controllers/tpi/sectors_controller.rb +++ b/app/controllers/tpi/sectors_controller.rb @@ -20,14 +20,10 @@ def index end @publications_and_articles = publications_and_articles sectors_page = TPIPage.find_by(slug: 'publicly-listed-equities-content') - @methodology_description = Content.find_by( - page: sectors_page, - code: 'methodology_description' - ) - @methodology_id = Content.find_by( - page: sectors_page, - code: 'methodology_publication_id' - ) + @methodology_description = Content.find_by(page: sectors_page, code: 'methodology_description') + @methodology_id = Content.find_by(page: sectors_page, code: 'methodology_publication_id') + @beta_methodology_id = Content.find_by(page: sectors_page, code: 'beta_methodology_publication_id') + @methodology_id = @beta_methodology_id || @methodology_id if session[:enable_beta_mq_assessments] @methodology_publication = Publication.find_by(id: @methodology_id&.text) fixed_navbar('Sectors', admin_tpi_sectors_path) diff --git a/app/helpers/mq_assessment_helper.rb b/app/helpers/mq_assessment_helper.rb new file mode 100644 index 000000000..17345bdd1 --- /dev/null +++ b/app/helpers/mq_assessment_helper.rb @@ -0,0 +1,7 @@ +module MQAssessmentHelper + def hide_mq_assessments_with_same_date(assessments) + result = [] + assessments.group_by(&:assessment_date).each { |_date, a| result << a.max_by(&:methodology_version) } + result + end +end diff --git a/app/javascript/components/tpi/MqBetaModal.jsx b/app/javascript/components/tpi/MqBetaModal.jsx index 9f3f4976e..d12274d85 100644 --- a/app/javascript/components/tpi/MqBetaModal.jsx +++ b/app/javascript/components/tpi/MqBetaModal.jsx @@ -6,7 +6,7 @@ import { OverlayProvider } from '@react-aria/overlays'; const TPI_MODAL_DISMISSED = 'TPI_MODAL_DISMISSED'; const TPI_MODAL_PAGES_SHOWN = 'TPI_MODAL_PAGES_SHOWN'; -const MQ_REPORT_PUBLICATION_LINK = '/static_files/23-10-20 MQ V5 Report for publication.pptx'; +const MQ_REPORT_PUBLICATION_LINK = '/static_files/Raising the Bar. TPI\'s new Management Quality framework.pdf'; const MqBetaModal = ({ enabled, page }) => { const [displayed, setDisplayed] = useState(false); @@ -63,7 +63,7 @@ const MqBetaModal = ({ enabled, page }) => { >
-The TPI Centre has developed an update to its Management Quality @@ -79,9 +79,8 @@ const MqBetaModal = ({ enabled, page }) => { website until at least September 2024.
- The detailed methodology note behind the BETA MQ methodology, - including a section discussing methodological differences between - it and the existing methodology, can be found here. + A report detailing what’s new in the BETA MQ methodology, + and a review of its impact on company scoring, can be found here.
Carbon Performance assessments are not affected by using this diff --git a/app/models/mq/assessment.rb b/app/models/mq/assessment.rb index 598e971b5..2e3b46082 100644 --- a/app/models/mq/assessment.rb +++ b/app/models/mq/assessment.rb @@ -49,7 +49,7 @@ def previous_assessments # keep select and sort by, company - mq assessments will be cached once company .mq_assessments - .currently_published + .select { |a| a.publication_date <= DateTime.now } .select { |a| a.assessment_date < assessment_date } .sort_by(&:assessment_date) end diff --git a/app/services/api/charts/mq_assessment.rb b/app/services/api/charts/mq_assessment.rb index e46061b28..5573ec921 100644 --- a/app/services/api/charts/mq_assessment.rb +++ b/app/services/api/charts/mq_assessment.rb @@ -34,7 +34,7 @@ def assessments_levels_data }, { name: 'Max Level', - data: assessment.beta_methodology? ? assessment.beta_levels.last.to_i : 4 + data: max_level } ] end @@ -47,9 +47,22 @@ def company_mq_assessments @company_mq_assessments ||= begin query = company.mq_assessments.currently_published.order(:assessment_date) query = query.without_beta_methodologies unless @enable_beta_mq_assessments - query + hide_mq_assessments_with_same_date query end end + + def max_level + beta_assessment = company_mq_assessments.detect(&:beta_methodology?) + return 4 unless beta_assessment.present? + + beta_assessment.beta_levels.last.to_i + end + + def hide_mq_assessments_with_same_date(assessments) + result = [] + assessments.group_by(&:assessment_date).each { |_date, a| result << a.max_by(&:methodology_version) } + result + end end end end diff --git a/app/services/api/charts/sector.rb b/app/services/api/charts/sector.rb index d0e1a4d46..4bfe2b50d 100644 --- a/app/services/api/charts/sector.rb +++ b/app/services/api/charts/sector.rb @@ -115,6 +115,7 @@ def companies_grouped_by_latest_assessment_level ) .map { |c| update_beta_mq_assessments_visibility c } .reject { |c| c.mq_level.nil? } + .select { |c| @enable_beta_mq_assessments ? c.latest_mq_assessment.beta_methodology? : true } .group_by { |c| c.mq_level.to_i.to_s } end @@ -126,6 +127,7 @@ def companies_grouped_by_sector :latest_mq_assessment_only_beta_methodologies ) .map { |c| update_beta_mq_assessments_visibility c } + .select { |c| @enable_beta_mq_assessments ? c.latest_mq_assessment.beta_methodology? : true } .group_by { |company| company.sector.name } end @@ -215,6 +217,10 @@ def update_beta_mq_assessments_visibility(company) company.show_beta_mq_assessments = @enable_beta_mq_assessments company end + + def keep_only_beta_mq_assessments(companies) + companies.select { |c| c.latest_mq_assessment.beta_methodology? } + end end end end diff --git a/app/views/tpi/companies/_mq_assessment.html.erb b/app/views/tpi/companies/_mq_assessment.html.erb index 1c70d9d08..11ef814f4 100644 --- a/app/views/tpi/companies/_mq_assessment.html.erb +++ b/app/views/tpi/companies/_mq_assessment.html.erb @@ -15,9 +15,9 @@
- Number of assessments: <%= @company_presenter.mq_assessments.size %> + Number of assessments: <%= hide_mq_assessments_with_same_date(@company_presenter.mq_assessments).size %>
<% if @company_presenter.mq_assessments.any? %> <%= render 'mq_level', level: @company.mq_level, status: @company.mq_status %> @@ -170,7 +170,7 @@ name: 'mq_assessment_id', remote: true, url: mq_assessment_tpi_company_path(@company), - data: @company_presenter.mq_assessments.map {|v| {label: v['assessment_date']&.strftime('%d %B %Y'), value: v['id']}}, + data: hide_mq_assessments_with_same_date(@company_presenter.mq_assessments).map {|v| {label: v['assessment_date']&.strftime('%d %B %Y'), value: v['id']}}, selected: params[:mq_assessment_id] }) %><%= publication.publication_date.strftime('%d/%m/%Y') %>
-