epb_view_models 2.1.4 → 2.1.5

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: 297a382293d1b6296686a0becea2a3dc30f5ef1fceafd92c822208146352112c
4
+ data.tar.gz: cc2ff6c08f0d7bb362181bd7628d8d5c88ce1dec432078062fce2c1a6e4ca40e
5
5
  SHA512:
6
- metadata.gz: 66871443879f52e577da10b8906591c6f6195bcc46e36e8a74a13965f8628dcbd3c777c08598be9f7f2d8ae1c2da0f29484520bda995cad9cf6350527111dee2
7
- data.tar.gz: b7ef0c3f454c3dba7479667c1e1f3062d569b8662e2dd9f1a57afcf7bc432f3bff456d413f0e521a2c8ffb4cb77c1237ae32c15e4e21e15d83d9ee6814a50597
6
+ metadata.gz: 44bfff8af36be2a9ce565be901b9ba79cdd8b30fe8c5376b650143a74667a7f64d32293c2f5a4dc37bcb2cc1ff15099f69631b5cffe7591c50d136ec12580229
7
+ data.tar.gz: 2e1fecda6730a8c9b8c3bf891d22b4cb59fe5a01d0bbe75220f793add923c186fe976af75a7046c71dee5ce008722bfb49f5d439ff3cb2c808b00d776bde4765
@@ -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.5"
9
9
  end
10
10
 
11
11
  # Monkey patching to avoid using ActiveRecord::Type::Boolean.new.cast
@@ -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.5
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-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri