epb_view_models 2.1.4 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0afd5a7caeb45cbe256054c67d7c2c48509d30f0cc30830e3158a7fdb2e799e
4
- data.tar.gz: 1d73a915230ecb63d67afca596b307fc4cf26849c46b8ea44623a6f76cd5cfb4
3
+ metadata.gz: 67b33f9ad33a22228573df03d85af550b72f881546c0801c48d937fcdb53dac4
4
+ data.tar.gz: 41bda340d96c83af50aaae4f0c5cebdd92604f2d3232533b28fdc47f711d8d89
5
5
  SHA512:
6
- metadata.gz: 66871443879f52e577da10b8906591c6f6195bcc46e36e8a74a13965f8628dcbd3c777c08598be9f7f2d8ae1c2da0f29484520bda995cad9cf6350527111dee2
7
- data.tar.gz: b7ef0c3f454c3dba7479667c1e1f3062d569b8662e2dd9f1a57afcf7bc432f3bff456d413f0e521a2c8ffb4cb77c1237ae32c15e4e21e15d83d9ee6814a50597
6
+ metadata.gz: 8572481d837b9edee24148897ab4d012fbacfdcc70e1bc470c06e3ce2d31e9332426e2ef504689c41e8e8440b25369a7ab67f8fa5c7a18d2d2bb104fe664c243
7
+ data.tar.gz: 83247d63d782f80ae83694728887d7fc2b16268c5eb0c0f2ae80d42e3df6906d4dd4493e75e946bdadc997a409830df6878e43f960f436b8bd867fbb9b3f7858
@@ -5,7 +5,7 @@ loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
5
5
  loader.setup
6
6
 
7
7
  module EpbViewModels
8
- VERSION = "2.1.4"
8
+ VERSION = "2.1.6"
9
9
  end
10
10
 
11
11
  # Monkey patching to avoid using ActiveRecord::Type::Boolean.new.cast
@@ -37,7 +37,7 @@ module Presenter
37
37
  main_benchmark: @view_model.main_benchmark,
38
38
  main_heating_fuel: @view_model.main_heating_fuel,
39
39
  special_energy_uses: @view_model.special_energy_uses,
40
- renewable_sources: @view_model.renewables_fuel_thermal,
40
+ renewable_sources: @view_model.respond_to?(:renewable_sources) ? @view_model.renewable_sources : nil,
41
41
  total_floor_area: @view_model.floor_area,
42
42
  occupancy_level: @view_model.occupancy_level,
43
43
  annual_thermal_fuel_usage: @view_model.annual_energy_use_fuel_thermal,
@@ -196,6 +196,10 @@ module ViewModel
196
196
  def other_fuel
197
197
  xpath(%w[Technical-Information Other-Fuel-Description])
198
198
  end
199
+
200
+ def renewable_sources
201
+ xpath(%w[Renewable-Sources])
202
+ end
199
203
  end
200
204
  end
201
205
  end
@@ -216,6 +216,10 @@ module ViewModel
216
216
  def other_fuel
217
217
  xpath(%w[Technical-Information Other-Fuel-Description])
218
218
  end
219
+
220
+ def renewable_sources
221
+ xpath(%w[Renewable-Sources])
222
+ end
219
223
  end
220
224
  end
221
225
  end
@@ -216,6 +216,10 @@ module ViewModel
216
216
  def other_fuel
217
217
  xpath(%w[Technical-Information Other-Fuel-Description])
218
218
  end
219
+
220
+ def renewable_sources
221
+ xpath(%w[Renewable-Sources])
222
+ end
219
223
  end
220
224
  end
221
225
  end
@@ -216,6 +216,10 @@ module ViewModel
216
216
  def other_fuel
217
217
  xpath(%w[Technical-Information Other-Fuel-Description])
218
218
  end
219
+
220
+ def renewable_sources
221
+ xpath(%w[Renewable-Sources])
222
+ end
219
223
  end
220
224
  end
221
225
  end
@@ -224,6 +224,10 @@ module ViewModel
224
224
  def other_fuel
225
225
  xpath(%w[Technical-Information Other-Fuel-Description])
226
226
  end
227
+
228
+ def renewable_sources
229
+ xpath(%w[Renewable-Sources])
230
+ end
227
231
  end
228
232
  end
229
233
  end
@@ -224,6 +224,10 @@ module ViewModel
224
224
  def other_fuel
225
225
  xpath(%w[Technical-Information Other-Fuel-Description])
226
226
  end
227
+
228
+ def renewable_sources
229
+ xpath(%w[Renewable-Sources])
230
+ end
227
231
  end
228
232
  end
229
233
  end
@@ -224,6 +224,10 @@ module ViewModel
224
224
  def other_fuel
225
225
  xpath(%w[Technical-Information Other-Fuel-Description])
226
226
  end
227
+
228
+ def renewable_sources
229
+ xpath(%w[Renewable-Sources])
230
+ end
227
231
  end
228
232
  end
229
233
  end
@@ -226,6 +226,10 @@ module ViewModel
226
226
  def building_category
227
227
  xpath(%w[Building-Category])
228
228
  end
229
+
230
+ def renewable_sources
231
+ xpath(%w[Renewable-Sources])
232
+ end
229
233
  end
230
234
  end
231
235
  end
@@ -224,6 +224,10 @@ module ViewModel
224
224
  def other_fuel
225
225
  xpath(%w[Technical-Information Other-Fuel-Description])
226
226
  end
227
+
228
+ def renewable_sources
229
+ xpath(%w[Renewable-Sources])
230
+ end
227
231
  end
228
232
  end
229
233
  end
@@ -125,6 +125,7 @@ module ViewModel
125
125
  {
126
126
  sequence: xpath(%w[Sequence], node).to_i,
127
127
  improvement_code: xpath(%w[Improvement-Details Improvement-Number], node),
128
+ # the schema version is set to 21.0.1 as 21.0.0 had missing improvements in the external definitions
128
129
  improvement_summary: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-21.0.1", improvement_number: improvement_code).summary : xpath(%w[Improvement-Summary], node),
129
130
  improvement_description: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-21.0.1", improvement_number: improvement_code).description : xpath(%w[Improvement-Description], node),
130
131
  indicative_cost: xpath(%w[Indicative-Cost], node),
@@ -125,8 +125,9 @@ module ViewModel
125
125
  {
126
126
  sequence: xpath(%w[Sequence], node).to_i,
127
127
  improvement_code: xpath(%w[Improvement-Details Improvement-Number], node),
128
- improvement_summary: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-NI-21.0.0", improvement_number: improvement_code).summary : xpath(%w[Improvement-Summary], node),
129
- improvement_description: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-NI-21.0.0", improvement_number: improvement_code).description : xpath(%w[Improvement-Description], node),
128
+ # the schema version is set to 21.0.1 as 21.0.0 had missing improvements in the external definitions
129
+ improvement_summary: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-NI-21.0.1", improvement_number: improvement_code).summary : xpath(%w[Improvement-Summary], node),
130
+ improvement_description: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-NI-21.0.1", improvement_number: improvement_code).description : xpath(%w[Improvement-Description], node),
130
131
  indicative_cost: xpath(%w[Indicative-Cost], node),
131
132
  }
132
133
  end
@@ -397,6 +398,41 @@ module ViewModel
397
398
  xpath(%w[Heated-Room-Count])&.to_i
398
399
  end
399
400
 
401
+ def low_energy_lighting
402
+ if fixed_lighting_outlets_count.zero?
403
+ return 0
404
+ end
405
+
406
+ ((low_energy_fixed_lighting_outlets_count.to_f / fixed_lighting_outlets_count) * 100).round
407
+ end
408
+
409
+ def fixed_lighting_outlets_count
410
+ fixed_lighting_outlets_count = low_energy_fixed_lighting_outlets_count
411
+ if xpath(%w[Incandescent-Fixed-Lighting-Bulbs-Count])
412
+ fixed_lighting_outlets_count += xpath(%w[Incandescent-Fixed-Lighting-Bulbs-Count])&.to_i
413
+ end
414
+ fixed_lighting_outlets_count
415
+ end
416
+
417
+ def low_energy_fixed_lighting_outlets_count
418
+ low_energy_fixed_lighting_outlets_count = 0
419
+ if xpath(%w[CFL-Fixed-Lighting-Bulbs-Count])
420
+ low_energy_fixed_lighting_outlets_count += xpath(%w[CFL-Fixed-Lighting-Bulbs-Count])&.to_i
421
+ end
422
+ if xpath(%w[LED-Fixed-Lighting-Bulbs-Count])
423
+ low_energy_fixed_lighting_outlets_count += xpath(%w[LED-Fixed-Lighting-Bulbs-Count])&.to_i
424
+ end
425
+ if xpath(%w[Low-Energy-Fixed-Lighting-Bulbs-Count])
426
+ low_energy_fixed_lighting_outlets_count += xpath(%w[Low-Energy-Fixed-Lighting-Bulbs-Count])&.to_i
427
+ end
428
+
429
+ low_energy_fixed_lighting_outlets_count
430
+ end
431
+
432
+ def open_fireplaces_count
433
+ xpath(%w[Open-Chimneys-Count])&.to_i
434
+ end
435
+
400
436
  def hot_water_description
401
437
  xpath(%w[Hot-Water Description])
402
438
  end
@@ -125,8 +125,8 @@ module ViewModel
125
125
  {
126
126
  sequence: xpath(%w[Sequence], node).to_i,
127
127
  improvement_code: xpath(%w[Improvement-Details Improvement-Number], node),
128
- improvement_summary: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-21.0.0", improvement_number: improvement_code).summary : xpath(%w[Improvement-Summary], node),
129
- improvement_description: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-21.0.0", improvement_number: improvement_code).description : xpath(%w[Improvement-Description], node),
128
+ improvement_summary: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-NI-21.0.1", improvement_number: improvement_code).summary : xpath(%w[Improvement-Summary], node),
129
+ improvement_description: improvement_code ? accessor.fetch_details(schema_version: "RdSAP-Schema-NI-21.0.1", improvement_number: improvement_code).description : xpath(%w[Improvement-Description], node),
130
130
  indicative_cost: xpath(%w[Indicative-Cost], node),
131
131
  }
132
132
  end
@@ -398,13 +398,17 @@ module ViewModel
398
398
  end
399
399
 
400
400
  def low_energy_lighting
401
- (low_energy_fixed_lighting_outlets_count / fixed_lighting_outlets_count) * 100
401
+ if fixed_lighting_outlets_count.zero?
402
+ return 0
403
+ end
404
+
405
+ ((low_energy_fixed_lighting_outlets_count.to_f / fixed_lighting_outlets_count) * 100).round
402
406
  end
403
407
 
404
408
  def fixed_lighting_outlets_count
405
409
  fixed_lighting_outlets_count = low_energy_fixed_lighting_outlets_count
406
- if xpath(%w[Incandescent-Lighting-Bulbs-Count])
407
- fixed_lighting_outlets_count += xpath(%w[Incandescent-Lighting-Bulbs-Count])&.to_i
410
+ if xpath(%w[Incandescent-Fixed-Lighting-Bulbs-Count])
411
+ fixed_lighting_outlets_count += xpath(%w[Incandescent-Fixed-Lighting-Bulbs-Count])&.to_i
408
412
  end
409
413
  fixed_lighting_outlets_count
410
414
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epb_view_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - MHCLG Energy Performance of Buildings
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-07-08 00:00:00.000000000 Z
11
+ date: 2025-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri