Skip to content

Commit

Permalink
Adjust specs to new heat modelling
Browse files Browse the repository at this point in the history
  • Loading branch information
redekok committed Jan 31, 2024
1 parent b108134 commit 1f4db7b
Show file tree
Hide file tree
Showing 20 changed files with 318 additions and 92 deletions.
4 changes: 2 additions & 2 deletions app/forms/dataset_edit_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class DatasetEditForm
# in the form (see CalculableValidator)
attribute :country, String

validates_presence_of :number_of_residences, :country
validates :number_of_residences, numericality: { greater_than: 0 }
validates_presence_of :number_of_inhabitants, :country
validates :number_of_inhabitants, numericality: { greater_than: 0 }
validates_with CalculableValidator

def submit(dataset)
Expand Down
2 changes: 2 additions & 0 deletions app/services/calculable_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ def validate(record)
*InterfaceElement.items.map(&:key)
)

puts record.attributes.reject{ |a,v| v.nil?}

begin
dataset = Dataset.new(
name: 'calculation_shell',
Expand Down
13 changes: 0 additions & 13 deletions config/charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,6 @@ number_of_cars:
- districts
- neighborhoods

number_of_residences:
legend_type: dynamic
unit: '#'
scale: log10
color_stops:
- "#009cff"
- "#000000"
layers:
- provinces
- municipalities
- districts
- neighborhoods

roof_surface_available_for_pv:
legend_type: dynamic
unit: '#'
Expand Down
220 changes: 210 additions & 10 deletions config/interface_elements/area/area_infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,49 +72,249 @@ groups:
unit: 'meter'
combination_method:
weighted_average:
- number_of_residences
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
- key: heat_length_of_distribution_pipelines_in_meter_per_residence_object_second_bracket
unit: 'meter'
combination_method:
weighted_average:
- number_of_residences
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
- key: heat_length_of_distribution_pipelines_in_meter_per_residence_object_third_bracket
unit: 'meter'
combination_method:
weighted_average:
- number_of_residences
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
- key: heat_length_of_distribution_pipelines_in_meter_per_residence_object_fourth_bracket
unit: 'meter'
combination_method:
weighted_average:
- number_of_residences
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
- key: heat_length_of_distribution_pipelines_in_meter_per_residence_object_fifth_bracket
unit: 'meter'
combination_method:
weighted_average:
- number_of_residences
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
- key: heat_length_of_connection_pipelines_in_meter_per_residence_first_bracket
unit: 'meter'
combination_method:
weighted_average:
- number_of_residences
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
- key: heat_length_of_connection_pipelines_in_meter_per_residence_second_bracket
unit: 'meter'
combination_method:
weighted_average:
- number_of_residences
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
- key: heat_length_of_connection_pipelines_in_meter_per_residence_third_bracket
unit: 'meter'
combination_method:
weighted_average:
- number_of_residences
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
- key: heat_length_of_connection_pipelines_in_meter_per_residence_fourth_bracket
unit: 'meter'
combination_method:
weighted_average:
- number_of_residences
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
- key: heat_length_of_connection_pipelines_in_meter_per_residence_fifth_bracket
unit: 'meter'
combination_method:
weighted_average:
- number_of_residences
- sum:
- present_number_of_apartments_before_1945
- present_number_of_apartments_1945_1964
- present_number_of_apartments_1965_1984
- present_number_of_apartments_1985_2004
- present_number_of_apartments_2005_present
- present_number_of_detached_houses_before_1945
- present_number_of_detached_houses_1945_1964
- present_number_of_detached_houses_1965_1984
- present_number_of_detached_houses_1985_2004
- present_number_of_detached_houses_2005_present
- present_number_of_semi_detached_houses_before_1945
- present_number_of_semi_detached_houses_1945_1964
- present_number_of_semi_detached_houses_1965_1984
- present_number_of_semi_detached_houses_1985_2004
- present_number_of_semi_detached_houses_2005_present
- present_number_of_terraced_houses_before_1945
- present_number_of_terraced_houses_1945_1964
- present_number_of_terraced_houses_1965_1984
- present_number_of_terraced_houses_1985_2004
- present_number_of_terraced_houses_2005_present
1 change: 0 additions & 1 deletion config/locales/en_charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ en:
heat_networks: "Heat networks"
number_of_inhabitants: "Number of inhabitants"
number_of_cars: "Number of cars"
number_of_residences: "Number of residences"
potential_heat_wko_neighborhood: "Potential heat storage WKO system per neighborhood"
roof_surface_available_for_pv: "Roof available for PV per household"
4 changes: 2 additions & 2 deletions spec/controllers/api/v1/exports_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
it 'fetches a collection of dataset edits as json' do
get :show, params: { id: dataset.geo_id }, format: :json

expect(body.fetch('number_of_residences')).to eq(10.0)
expect(body.fetch('present_number_of_apartments_before_1945')).to eq(84.0)
end

describe 'with edits' do
Expand All @@ -29,7 +29,7 @@
it 'should render all the editable attributes of a dataset' do
get :show, params: { id: dataset.geo_id }, format: :json

expect(body.fetch('number_of_residences')).to eq(10.0)
expect(body.fetch('present_number_of_apartments_before_1945')).to eq(84.0)
end

it 'should render all the editable attributes of a dataset' do
Expand Down
10 changes: 5 additions & 5 deletions spec/controllers/commits_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def request_dataset_edits
dataset_id: dataset.id,
dataset_edit_form: {
dataset_id: dataset.id,
number_of_residences: 15,
number_of_cars: 15,
number_of_inhabitants: 50
}
}, format: :js, xhr: true
Expand Down Expand Up @@ -57,8 +57,8 @@ def request_dataset_edits
{
dataset_edits_attributes: [
{
"key"=>"number_of_buildings",
"value"=>"0.25"
"key"=>"number_of_cars",
"value"=>"25.0"
}
]
}
Expand Down Expand Up @@ -86,8 +86,8 @@ def request_dataset_edits
{
dataset_edits_attributes: {
"0"=>{
"key"=>"number_of_buildings",
"value"=>"0.25"
"key"=>"number_of_cars",
"value"=>"25.0"
},
"1"=>{
"key"=>"electricity_consumption",
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/commits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
after(:create) do |commit|
FactoryBot.create(
:dataset_edit,
key: 'number_of_residences',
key: 'present_number_of_apartments_before_1945',
value: 1.0,
commit: commit
)
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/areas/grootebroek.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ gas_consumption: 2500 # m3
electricity_consumption: 400 # kWh
roof_surface_available_for_pv: 50 # m2
number_of_cars: 30
number_of_residences: 50
number_of_residences_with_solar_pv: 5
present_number_of_apartments_before_1945: 50
present_number_of_apartments_before_1945_with_solar_pv: 5
number_of_inhabitants: 100
percentage_of_old_residences: 1
building_area: 20
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/areas/lutjebroek.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
electricity_consumption: 400 # kWh
roof_surface_available_for_pv: 50 # m2
number_of_cars: 30
number_of_residences: 50
number_of_residences_with_solar_pv: 5
present_number_of_apartments_before_1945: 50
present_number_of_apartments_before_1945_with_solar_pv: 5
number_of_inhabitants: 100
Loading

0 comments on commit 1f4db7b

Please sign in to comment.