Skip to content

Commit 1574baa

Browse files
authored
Merge pull request #742 from citizensadvice/new-supplier-data-layout
chore/Add new CSR data
2 parents fff307c + 7f346bb commit 1574baa

28 files changed

+1016
-825
lines changed

app/assets/stylesheets/components/_index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
@import "./supplier-table-row";
1010
@import "./unranked-supplier";
1111
@import "./score-summary";
12-
@import "./other-scores";
12+
@import "./section-scores";

app/assets/stylesheets/components/_other-scores.scss renamed to app/assets/stylesheets/components/_section-scores.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.other-scores {
1+
.section-scores, .other-scores {
22
margin-bottom: $cads-spacing-7;
33

44
h2 {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.cads-grid-row
2+
.cads-grid-col-md-9
3+
.section-scores
4+
%h2 Billing and metering
5+
.cads-prose
6+
%p
7+
We measure billing accuracy by looking at how many bills are based on a meter reading, rather than an estimate.
8+
= render CsrTable::DescriptionListComponent.new do |c|
9+
- c.with_descriptions(descriptions)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# frozen_string_literal: true
2+
3+
module CsrTable
4+
class BillingAndMeteringScoresComponent < ViewComponent::Base
5+
attr_reader :supplier, :renderer
6+
7+
def initialize(supplier)
8+
super()
9+
@supplier = supplier
10+
@renderer = Renderers::RichTextRenderer.new
11+
end
12+
13+
def render?
14+
supplier.present?
15+
end
16+
17+
def descriptions
18+
[
19+
bills_accuracy_smart,
20+
bills_accuracy_traditional,
21+
smart_operating
22+
]
23+
end
24+
25+
def bills_accuracy_smart
26+
{
27+
term: content_tag(:p, "Bills accuracy (smart meters) "),
28+
description: content_tag(:p, "#{supplier.bills_accuracy_smart}%")
29+
}
30+
end
31+
32+
def bills_accuracy_traditional
33+
{
34+
term: content_tag(:p, "Bills accuracy (traditional meters)"),
35+
description: content_tag(:p, "#{supplier.bills_accuracy_traditional}%")
36+
}
37+
end
38+
39+
def smart_operating
40+
{
41+
term: content_tag(:p, "Smart meters working correctly"),
42+
description: content_tag(:p, "#{supplier.smart_operating}%")
43+
}
44+
end
45+
end
46+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.cads-grid-row
2+
.cads-grid-col-md-9
3+
.section-scores
4+
%h2 Complaints received
5+
.cads-prose
6+
%p
7+
If a supplier gets a low number of complaints, we give them a higher star rating.
8+
= render CsrTable::DescriptionListComponent.new do |c|
9+
- c.with_descriptions(descriptions)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
module CsrTable
4+
class ComplaintsScoresComponent < ViewComponent::Base
5+
attr_reader :supplier, :renderer
6+
7+
def initialize(supplier)
8+
super()
9+
@supplier = supplier
10+
@renderer = Renderers::RichTextRenderer.new
11+
end
12+
13+
def render?
14+
supplier.present?
15+
end
16+
17+
def descriptions
18+
[
19+
{
20+
term: content_tag(:p, "Complaints to Citizens Advice, Advice Direct Scotland and the Energy Ombudsman"),
21+
description: content_tag(:p, "#{supplier.complaints_number} per 10,000 customers")
22+
}
23+
]
24+
end
25+
end
26+
end

app/controllers/queries/supplier_detail.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ module Queries
3232
overallRating,
3333
dataAvailable,
3434
billAccuracyAndMeteringRating,
35+
billsAccuracySmart,
36+
billsAccuracyTraditional,
37+
smartOperating,
3538
guaranteeList {
3639
json
3740
},

app/models/supplier.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ class Supplier
1010
:contact_social_media, :contact_time, :contact_info,
1111
:other_contact_info, :billing_info, :guarantee_rating,
1212
:guarantee_list, :overall_rating, :data_available, :fuel_mix,
13-
:opening_hours, :bill_accuracy_and_metering_rating, to: :data
13+
:opening_hours, :bill_accuracy_and_metering_rating,
14+
:bills_accuracy_smart, :bills_accuracy_traditional,
15+
:smart_operating, to: :data
1416

1517
def self.fetch_all
1618
response = Contentful::Graphql::Client.query(Queries::Suppliers)

app/views/csr_table/suppliers/show.html.haml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,23 @@
2424
%p
2525
= link_to("Check the full table to compare more energy suppliers' customer service", suppliers_path(country: current_country))
2626

27-
= render CsrTable::OtherScoresComponent.new(supplier)
28-
29-
.cads-prose
30-
%p
31-
= link_to("Find out how the scores are worked out", country_url("/consumer/energy/energy-supply/get-a-better-energy-deal/compare-domestic-energy-suppliers-customer-service1/how-the-scores-are-worked-out/"))
27+
- if Feature.enabled?("FF_NEW_CSR_DATA")
28+
.cads-prose
29+
%h2
30+
More information
31+
%p
32+
We give energy suppliers a score out of 5 for each category, based on various data. You can look at this data in more detail below.
33+
%p
34+
= link_to("Find out how the scores are worked out", country_url("/consumer/energy/energy-supply/get-a-better-energy-deal/compare-domestic-energy-suppliers-customer-service1/how-the-scores-are-worked-out/"))
35+
= render CsrTable::ComplaintsScoresComponent.new(supplier)
36+
= render CsrTable::BillingAndMeteringScoresComponent.new(supplier)
37+
38+
- else
39+
= render CsrTable::OtherScoresComponent.new(supplier)
40+
41+
.cads-prose
42+
%p
43+
= link_to("Find out how the scores are worked out", country_url("/consumer/energy/energy-supply/get-a-better-energy-deal/compare-domestic-energy-suppliers-customer-service1/how-the-scores-are-worked-out/"))
3244

3345
= render CsrTable::FuelMixComponent.new(supplier)
3446

db/schema.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)