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 }) => { >
-
Management Quality (MQ) methodology
+
Management Quality methodology

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 @@

-
Nr of assessments: <%= assessment.previous_assessments.size + 1 %>
+
Nr of assessments: <%= hide_mq_assessments_with_same_date(assessment.previous_assessments).size + 1 %>
- Number of assessments: <%= assessment.previous_assessments.size + 1 %> + Number of assessments: <%= hide_mq_assessments_with_same_date(assessment.previous_assessments).size + 1 %>
<%= react_component('charts/mq-level', { diff --git a/app/views/tpi/companies/show.html.erb b/app/views/tpi/companies/show.html.erb index 90cf136bc..1ec8bd51f 100644 --- a/app/views/tpi/companies/show.html.erb +++ b/app/views/tpi/companies/show.html.erb @@ -74,7 +74,7 @@

Management Quality

- 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] }) %>
diff --git a/app/views/tpi/publications/_list.html.erb b/app/views/tpi/publications/_list.html.erb index d11cbf1c3..00526d4e7 100644 --- a/app/views/tpi/publications/_list.html.erb +++ b/app/views/tpi/publications/_list.html.erb @@ -18,6 +18,15 @@ <% end %>
+ +
+ <% if publication.is_a?(NewsArticle) %> + <%= publication.is_insight? ? 'Insights' : 'News' %> + <% else %> + Publications + <% end %> +
+

<%= publication.publication_date.strftime('%d/%m/%Y') %>

@@ -29,13 +38,7 @@ <% end %>

-
- <% if publication.is_a?(NewsArticle) %> - <%= publication.is_insight? ? 'Insights' : 'News' %> - <% else %> - Publications - <% end %> -
+ <% if publication.keywords.any? || publication.tpi_sectors.any? %>
<% publication.tags_and_sectors.each do |tag| %> diff --git a/app/views/tpi/publications/show.html.erb b/app/views/tpi/publications/show.html.erb index 408a04200..92fbb2461 100644 --- a/app/views/tpi/publications/show.html.erb +++ b/app/views/tpi/publications/show.html.erb @@ -7,19 +7,20 @@

<%= @publication.title %>

<%= @publication.publication_date.strftime('%d/%m/%Y') %>

-
+
<% if @publication.image.present? %>
<%= image_tag(@publication.image) %>
<% end %> -
-

<%= @publication.short_description %>

+
<% if @publication.keywords.any? || @publication.tpi_sectors.any? %> -
+
<% @publication.tags_and_sectors.each do |tag| %> <%= tag %> <% end %>
<% end %> +

<%= @publication.short_description %>

+
<%= @publication.summary&.html_safe %>
diff --git a/public/static_files/23-10-20 MQ V5 Report for publication.pptx b/public/static_files/23-10-20 MQ V5 Report for publication.pptx deleted file mode 100644 index ae16236bc..000000000 Binary files a/public/static_files/23-10-20 MQ V5 Report for publication.pptx and /dev/null differ diff --git a/public/static_files/Raising the Bar. TPI's new Management Quality framework.pdf b/public/static_files/Raising the Bar. TPI's new Management Quality framework.pdf new file mode 100644 index 000000000..14d14e448 Binary files /dev/null and b/public/static_files/Raising the Bar. TPI's new Management Quality framework.pdf differ diff --git a/spec/services/api/charts/mq_assessment_spec.rb b/spec/services/api/charts/mq_assessment_spec.rb index f318fae5d..dcc8bd75c 100644 --- a/spec/services/api/charts/mq_assessment_spec.rb +++ b/spec/services/api/charts/mq_assessment_spec.rb @@ -17,6 +17,7 @@ create(:mq_assessment, company: company, assessment_date: '2018-08-08', publication_date: '2018-08-08', level: '2') create(:mq_assessment, company: company, assessment_date: '2019-02-02', publication_date: '2019-02-02', level: '4') create(:mq_assessment, company: company, assessment_date: '2020-03-03', publication_date: '2020-03-03', level: '3') + create(:mq_assessment, company: company, assessment_date: '2021-03-03', publication_date: '2021-03-03', level: '4') # beta scores create(:mq_assessment, company: company, @@ -43,7 +44,8 @@ ['01/01/2018', 3], ['08/08/2018', 2], ['02/02/2019', 4], - ['03/03/2020', 3] + ['03/03/2020', 3], + ['03/03/2021', 4] ], name: 'Level' }, @@ -64,7 +66,7 @@ context 'when beta assessments are enabled' do subject do described_class.new( - company.mq_assessments.where(assessment_date: '2021-03-03').first, + company.mq_assessments.where(assessment_date: '2021-03-03', methodology_version: beta_methodology).first, enable_beta_mq_assessments: true ) end diff --git a/spec/services/api/charts/sector_spec.rb b/spec/services/api/charts/sector_spec.rb index 6e67855b4..0d3dc820d 100644 --- a/spec/services/api/charts/sector_spec.rb +++ b/spec/services/api/charts/sector_spec.rb @@ -5,6 +5,7 @@ let_it_be(:sector2) { create(:tpi_sector, name: 'Autos') } let_it_be(:company) { create(:company, sector: sector) } let_it_be(:company2) { create(:company, sector: sector2) } + let_it_be(:company3) { create(:company, sector: sector2) } let_it_be(:beta_methodology_version) { MQ::Assessment::BETA_METHODOLOGIES.keys.first } let_it_be(:beta_level) { MQ::Assessment::BETA_METHODOLOGIES[beta_methodology_version][:levels].first } @@ -36,6 +37,13 @@ level: beta_level, methodology_version: beta_methodology_version ) + create( + :mq_assessment, + company: company3, + assessment_date: '2020-01-01', + level: 3, + methodology_version: beta_methodology_version + ) # should be ignored create( :mq_assessment, @@ -128,7 +136,18 @@ '4' => [] }, sector2.name => { - '0' => [], + '0' => [ + { + name: company3.name, + slug: company3.slug, + path: company3.path, + sector: company3.sector.name, + market_cap_group: company3.market_cap_group, + level: company3.mq_level.to_i.to_s, + level4STAR: false, + status: company3.mq_status + } + ], '1' => [], '2' => [], '3' => [], @@ -158,10 +177,10 @@ '0' => [], '1' => [], '2' => [], - '3' => [], - '4' => [ - {id: company2.id, name: company2.name, status: 'new', level: '4STAR', slug: company2.slug} + '3' => [ + {id: company3.id, name: company3.name, status: 'new', level: '3', slug: company3.slug} ], + '4' => [], beta_level => [ {id: company.id, name: company.name, status: 'unchanged', level: beta_level, slug: company.slug} ] @@ -175,8 +194,8 @@ '0' => 0, '1' => 0, '2' => 0, - '3' => 0, - '4' => 1, + '3' => 1, + '4' => 0, beta_level => 1 ) end @@ -208,19 +227,19 @@ '0' => [], '1' => [], '2' => [], - '3' => [], - '4' => [ + '3' => [ { - name: company2.name, - slug: company2.slug, - path: company2.path, - sector: company2.sector.name, - market_cap_group: company2.market_cap_group, - level: company2.mq_level.to_i.to_s, - level4STAR: true, - status: company2.mq_status + name: company3.name, + slug: company3.slug, + path: company3.path, + sector: company3.sector.name, + market_cap_group: company3.market_cap_group, + level: '3', + level4STAR: false, + status: 'new' } ], + '4' => [], beta_level => [] } )