Skip to content

Commit

Permalink
added solution model and import default data
Browse files Browse the repository at this point in the history
  • Loading branch information
dereke committed Oct 21, 2019
1 parent ed8ca9e commit b49beaf
Show file tree
Hide file tree
Showing 23 changed files with 429 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/models/sector.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class Sector < ApplicationRecord
has_many :themes, dependent: :destroy
end
5 changes: 5 additions & 0 deletions app/models/solution.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class Solution < ApplicationRecord
# has_many :solution_classes
end
5 changes: 5 additions & 0 deletions app/models/solution_class.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class SolutionClass < ApplicationRecord
belongs_to :theme
end
6 changes: 6 additions & 0 deletions app/models/solution_solution_class.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

class SolutionSolutionClass < ApplicationRecord
belongs_to :solution
belongs_to :solution_class
end
6 changes: 6 additions & 0 deletions app/models/theme.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

class Theme < ApplicationRecord
belongs_to :sector
has_many :solution_classes, dependent: :destroy
end
11 changes: 11 additions & 0 deletions db/migrate/20191021195819_create_sectors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class CreateSectors < ActiveRecord::Migration[6.0]
def change
create_table :sectors do |t|
t.string :name

t.timestamps
end
end
end
12 changes: 12 additions & 0 deletions db/migrate/20191021195835_create_themes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class CreateThemes < ActiveRecord::Migration[6.0]
def change
create_table :themes do |t|
t.string :name
t.references :sector, null: false, foreign_key: true

t.timestamps
end
end
end
12 changes: 12 additions & 0 deletions db/migrate/20191021195858_create_solution_classes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class CreateSolutionClasses < ActiveRecord::Migration[6.0]
def change
create_table :solution_classes do |t|
t.string :name
t.references :theme, null: false, foreign_key: true

t.timestamps
end
end
end
11 changes: 11 additions & 0 deletions db/migrate/20191021195926_create_solutions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class CreateSolutions < ActiveRecord::Migration[6.0]
def change
create_table :solutions do |t|
t.string :name

t.timestamps
end
end
end
12 changes: 12 additions & 0 deletions db/migrate/20191021195951_create_solution_solution_classes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class CreateSolutionSolutionClasses < ActiveRecord::Migration[6.0]
def change
create_table :solution_solution_classes do |t|
t.references :solution, null: false, foreign_key: true
t.references :solution_class, null: false, foreign_key: true

t.timestamps
end
end
end
45 changes: 44 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_10_05_213108) do
ActiveRecord::Schema.define(version: 2019_10_21_195951) do
# These are extensions that must be enabled in order to support this database
enable_extension 'plpgsql'

Expand Down Expand Up @@ -83,12 +83,51 @@
t.index %w[status_id], name: 'index_initiatives_on_status_id'
end

create_table 'sectors', force: :cascade do |t|
t.string 'name'
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
end

create_table 'solution_classes', force: :cascade do |t|
t.string 'name'
t.bigint 'theme_id', null: false
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
t.index %w[theme_id], name: 'index_solution_classes_on_theme_id'
end

create_table 'solution_solution_classes', force: :cascade do |t|
t.bigint 'solution_id', null: false
t.bigint 'solution_class_id', null: false
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
t.index %w[solution_class_id],
name: 'index_solution_solution_classes_on_solution_class_id'
t.index %w[solution_id],
name: 'index_solution_solution_classes_on_solution_id'
end

create_table 'solutions', force: :cascade do |t|
t.string 'name'
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
end

create_table 'tags', force: :cascade do |t|
t.string 'name'
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
end

create_table 'themes', force: :cascade do |t|
t.string 'name'
t.bigint 'sector_id', null: false
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
t.index %w[sector_id], name: 'index_themes_on_sector_id'
end

create_table 'users', force: :cascade do |t|
t.string 'email', default: '', null: false
t.string 'encrypted_password', default: '', null: false
Expand All @@ -107,4 +146,8 @@
add_foreign_key 'group_websites', 'groups'
add_foreign_key 'initiatives', 'groups', column: 'lead_group_id'
add_foreign_key 'initiatives', 'initiative_statuses', column: 'status_id'
add_foreign_key 'solution_classes', 'themes'
add_foreign_key 'solution_solution_classes', 'solution_classes'
add_foreign_key 'solution_solution_classes', 'solutions'
add_foreign_key 'themes', 'sectors'
end
196 changes: 196 additions & 0 deletions import/taxonomy.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
"idx","sector","theme","class","solution"
6,"Buildings & Their Environment","Building Development","Construction","Green Roofs"
4,"Buildings & Their Environment","Building Development","Construction","Net Zero Buildings"
5,"Buildings & Their Environment","Building Development","Construction","PassivHaus"
7,"Buildings & Their Environment","Building Development","Construction","Pedestrianisation"
9,"Buildings & Their Environment","Building Development","Smart Building","Building Automation"
11,"Buildings & Their Environment","Building Development","Smart Building","Smart Glass"
10,"Buildings & Their Environment","Building Development","Smart Building","Smart Thermostat / Meter"
39,"Buildings & Their Environment","Building Environment","Vehicle Access","Site EV Charging"
34,"Buildings & Their Environment","Building Environment","Water (Urban)","Greywater Applications"
32,"Buildings & Their Environment","Building Environment","Water (Urban)","Reduced Water Use"
37,"Buildings & Their Environment","Building Environment","Water (Urban)","Urban Flood Management"
33,"Buildings & Their Environment","Building Environment","Water (Urban)","Water Capture"
36,"Buildings & Their Environment","Building Environment","Water (Urban)","Water Fountains"
35,"Buildings & Their Environment","Building Environment","Water (Urban)","Water Refill Schemes"
21,"Buildings & Their Environment","Building Performance","Heating","Air-Source Heat Pump (ASHP)"
20,"Buildings & Their Environment","Building Performance","Heating","District Heating"
22,"Buildings & Their Environment","Building Performance","Heating","Ground-Source Heat Pump (GSHP)"
23,"Buildings & Their Environment","Building Performance","Heating","Hydrogen-Cell Heating"
18,"Buildings & Their Environment","Building Performance","Insulation","Double Glazing"
17,"Buildings & Their Environment","Building Performance","Insulation","Draft Exclusion"
16,"Buildings & Their Environment","Building Performance","Insulation","Floor Insulation"
14,"Buildings & Their Environment","Building Performance","Insulation","Loft Insulation"
15,"Buildings & Their Environment","Building Performance","Insulation","Wall Insulation"
25,"Buildings & Their Environment","Building Performance","Lighting","LED Lighting (Household)"
26,"Buildings & Their Environment","Building Performance","Lighting","LED Lighting (Public)"
28,"Buildings & Their Environment","Building Performance","Retrofitting","House Surveying"
29,"Buildings & Their Environment","Building Performance","Retrofitting","Retrofitting Service"
64,"Energy","Electricity Generation","Bio-energy","Biomethane generation"
63,"Energy","Electricity Generation","Bio-energy","Energy crops"
59,"Energy","Electricity Generation","Geothermal","Binary Cycle Geothermal"
60,"Energy","Electricity Generation","Geothermal","Dry Steam Geothermal"
61,"Energy","Electricity Generation","Geothermal","Flash Steam Geothermal"
54,"Energy","Electricity Generation","Micro Hydro","Archimedean Screw"
55,"Energy","Electricity Generation","Micro Hydro","Crossflow Turbine"
56,"Energy","Electricity Generation","Micro Hydro","Kaplan Turbine"
57,"Energy","Electricity Generation","Micro Hydro","Pelton & Turgo Turbines"
44,"Energy","Electricity Generation","Solar PV","Rooftop Solar PV"
45,"Energy","Electricity Generation","Solar PV","Solar PV Farms"
51,"Energy","Electricity Generation","Tidal & Wave","Tidal Lagoon"
52,"Energy","Electricity Generation","Tidal & Wave","Wave Power"
47,"Energy","Electricity Generation","Wind","Micro Wind"
48,"Energy","Electricity Generation","Wind","Wind Turbines (Offshore)"
49,"Energy","Electricity Generation","Wind","Wind Turbines (Onshore)"
67,"Energy","Energy Distribution","Electricity Grid","Grid Flexibility"
68,"Energy","Energy Distribution","Electricity Grid","Microgrids"
72,"Energy","Energy Distribution","Gas Network","Synth-Ammonia Network"
71,"Energy","Energy Distribution","Gas Network","Synth-Hydrogen Network"
70,"Energy","Energy Distribution","Gas Network","Synth-Methane Network"
79,"Energy","Energy Storage","Battery Storage","Distributed Battery Storage"
78,"Energy","Energy Storage","Battery Storage","Domestic Battery Storage"
80,"Energy","Energy Storage","Battery Storage","Utility Scale Battery Storage"
84,"Energy","Energy Storage","Chemical Storage","Synth-Ammonia Storage"
83,"Energy","Energy Storage","Chemical Storage","Synth-Hydrogen Storage"
82,"Energy","Energy Storage","Chemical Storage","Synth-Methane Storage"
76,"Energy","Energy Storage","Gravitational Energy","Hydraulic Rock Storage"
75,"Energy","Energy Storage","Gravitational Energy","Pumped Storage"
92,"Energy","Thermal Energy Generation","Combined Heat & Power (CHP)","Distributed CHP"
91,"Energy","Thermal Energy Generation","Combined Heat & Power (CHP)","Site-Based CHP"
88,"Energy","Thermal Energy Generation","Solar Thermal","Community Solar Thermal"
89,"Energy","Thermal Energy Generation","Solar Thermal","Industrial Solar Thermal"
87,"Energy","Thermal Energy Generation","Solar Thermal","Rooftop Solar Thermal"
96,"Food","Agriculture & Land ","Farm Management","Farmland Irrigation"
97,"Food","Agriculture & Land ","Farm Management","Farmland Restoration"
103,"Food","Agriculture & Land ","Grassland","Managed Grazing"
99,"Food","Agriculture & Land ","Soil Improvement","Conservation Agriculture"
100,"Food","Agriculture & Land ","Soil Improvement","Nutrient Management"
101,"Food","Agriculture & Land ","Soil Improvement","Regenerative Agriculture"
128,"Food","Community Food","Community Food Distribution","Foodbank"
126,"Food","Community Food","Community Food Distribution","Local Market"
127,"Food","Community Food","Community Food Distribution","Produce Sharing"
130,"Food","Community Food","Community Food Preparation","Community Kitchen"
131,"Food","Community Food","Community Food Preparation","Prepared Food Products"
120,"Food","Community Food","Community Gardens","Edible Open Garden"
122,"Food","Community Food","Community Gardens","Permaculture"
123,"Food","Community Food","Community Gardens","Silvopasture"
124,"Food","Community Food","Community Gardens","Tree Intercropping"
121,"Food","Community Food","Community Gardens","Urban Food Growing"
117,"Food","Diet & Cooking","Diet & Cooking Education","Vegan Courses"
116,"Food","Diet & Cooking","Diet & Cooking Education","Vegetarian Courses"
106,"Food","Diet & Cooking","Green Food Suppliers & Outlets","Green Fruit & Veg"
107,"Food","Diet & Cooking","Green Food Suppliers & Outlets","Organic Dairy"
109,"Food","Diet & Cooking","Green Food Suppliers & Outlets","Organic Other Foodstuff"
108,"Food","Diet & Cooking","Green Food Suppliers & Outlets","Vegan Foodstuff"
114,"Food","Diet & Cooking","Green Hospitality","Low Carbon Cooking Solutions"
113,"Food","Diet & Cooking","Green Hospitality","Other Green Hospitality"
112,"Food","Diet & Cooking","Green Hospitality","Vegan Hospitality"
111,"Food","Diet & Cooking","Green Hospitality","Vegetarian Hospitality"
134,"Food","Food Waste","Food Waste Reduce","Food Boxes"
138,"Food","Food Waste","Food Waste Reuse","Biochar"
136,"Food","Food Waste","Food Waste Reuse","Composting"
137,"Food","Food Waste","Food Waste Reuse","Food Waste Collection"
222,"Materials","Low Carbon Materials","Alternative Materials","Alternative Cement"
223,"Materials","Low Carbon Materials","Alternative Materials","Bioplastic"
224,"Materials","Low Carbon Materials","Alternative Materials","Plastic Alternative Containers & Wrapping"
225,"Materials","Low Carbon Materials","Alternative Materials","Steel Beam Replacement"
228,"Materials","Low Carbon Materials","Traditional Materials","Clay Render"
230,"Materials","Low Carbon Materials","Traditional Materials","Hempcrete"
227,"Materials","Low Carbon Materials","Traditional Materials","Lime Mortar"
231,"Materials","Low Carbon Materials","Traditional Materials","Straw/ Hemp/ Mud "
229,"Materials","Low Carbon Materials","Traditional Materials","Wood Products"
234,"Materials","Preventative Measures","F-gas Release Avoidance","Refrigerant Management"
200,"Nature, Conservation & Environment","Environmental Conservation","Forests & Woodland","Afforestation"
201,"Nature, Conservation & Environment","Environmental Conservation","Forests & Woodland","Hedgerow Restoration"
199,"Nature, Conservation & Environment","Environmental Conservation","Forests & Woodland","Reforestation"
198,"Nature, Conservation & Environment","Environmental Conservation","Forests & Woodland","Woodland Management"
204,"Nature, Conservation & Environment","Environmental Conservation","Wetlands","Coastal Wetland"
203,"Nature, Conservation & Environment","Environmental Conservation","Wetlands","Peatland"
208,"Nature, Conservation & Environment","Species Conservation","Habitat Conservation","Insect Habitats"
207,"Nature, Conservation & Environment","Species Conservation","Habitat Conservation","Plant Habitats"
209,"Nature, Conservation & Environment","Species Conservation","Habitat Conservation","Vertebrate Habitats"
211,"Nature, Conservation & Environment","Species Conservation","Transforming Habitats","Connecting Habitats"
212,"Nature, Conservation & Environment","Species Conservation","Transforming Habitats","Rewilding"
216,"Nature, Conservation & Environment","Weather Impact Management","Flooding","Flood Management"
215,"Nature, Conservation & Environment","Weather Impact Management","Flooding","Rural Sustainable Drainage (RSuDS)"
218,"Nature, Conservation & Environment","Weather Impact Management","Heatwave","Heatwave Resilience"
146,"Stakeholder","Engagement","Events","Conferences"
147,"Stakeholder","Engagement","Events","Festivals"
148,"Stakeholder","Engagement","Events","Gatherings"
149,"Stakeholder","Engagement","Events","Talks"
142,"Stakeholder","Engagement","Processes","Deliberative Process"
144,"Stakeholder","Engagement","Processes","Local Group Forum"
143,"Stakeholder","Engagement","Processes","Workshop"
152,"Stakeholder","Engagement","Surveying & Mapping","Business Questionnaire"
153,"Stakeholder","Engagement","Surveying & Mapping","Group / Initiative Questionnaire"
151,"Stakeholder","Engagement","Surveying & Mapping","Initiatives Mapping"
154,"Stakeholder","Engagement","Surveying & Mapping","Public Surveying"
190,"Stakeholder","Funding","Banking & Markets","Debentures"
189,"Stakeholder","Funding","Banking & Markets","Loans"
185,"Stakeholder","Funding","Community Funding","Community Shares"
186,"Stakeholder","Funding","Community Funding","Crowd Funding"
187,"Stakeholder","Funding","Community Funding","Pro bono"
193,"Stakeholder","Funding","Public ","Donation Appeals"
194,"Stakeholder","Funding","Public ","Fundraising Events"
192,"Stakeholder","Funding","Public ","Grants"
178,"Stakeholder","Local Government","Planning","Carbon Neutral Planning"
179,"Stakeholder","Local Government","Planning","Climate Emergency Plan"
181,"Stakeholder","Local Government","Planning","Local Planning"
182,"Stakeholder","Local Government","Planning","Local Transport Planning"
180,"Stakeholder","Local Government","Planning","Neighbourhood Planning"
170,"Stakeholder","Local Government","Policy","Declarations & Resolutions"
171,"Stakeholder","Local Government","Policy","Environmental Policies"
172,"Stakeholder","Local Government","Policy","Low Carbon Development Policies"
174,"Stakeholder","Local Government","Strategies","Carbon Neutral Strategy"
176,"Stakeholder","Local Government","Strategies","Resilience Strategy"
175,"Stakeholder","Local Government","Strategies","Sustainable Energy Strategy"
157,"Stakeholder","Services ","Advisory Service","Experts Network"
158,"Stakeholder","Services ","Advisory Service","Facilitation Service"
159,"Stakeholder","Services ","Advisory Service","Feasibility Service"
161,"Stakeholder","Services ","Advisory Service","Knowledge Transfer"
160,"Stakeholder","Services ","Advisory Service","Project Review Service"
164,"Stakeholder","Services ","Communication Service","Case Studies"
163,"Stakeholder","Services ","Communication Service","Good Practice Guides"
165,"Stakeholder","Services ","Communication Service","Leaflets, Posters & Handouts"
166,"Stakeholder","Services ","Communication Service","Learning Content"
167,"Stakeholder","Services ","Communication Service","Publications"
262,"Transport","Greening Heavy Transport","Goods Road Transport","Hydrogen-Cell Trucks"
261,"Transport","Greening Heavy Transport","Goods Road Transport","Warehousing"
268,"Transport","Greening Heavy Transport","Low Carbon Air Transport","VariaLift Airship"
264,"Transport","Greening Heavy Transport","Rail Transport","Train Electrification"
266,"Transport","Greening Heavy Transport","Shipping & Waterways","Canal Barge"
254,"Transport","Greening Vehicle Use","Buses, Trams & Light Railway","Bus Services"
255,"Transport","Greening Vehicle Use","Buses, Trams & Light Railway","Community Buses"
256,"Transport","Greening Vehicle Use","Buses, Trams & Light Railway","EV Buses"
258,"Transport","Greening Vehicle Use","Buses, Trams & Light Railway","Hydrogen-Cell Buses"
257,"Transport","Greening Vehicle Use","Buses, Trams & Light Railway","Trams & Light Railway "
250,"Transport","Greening Vehicle Use","Cars","Car Club"
251,"Transport","Greening Vehicle Use","Cars","Electric Vehicles"
252,"Transport","Greening Vehicle Use","Cars","EV Charging"
249,"Transport","Greening Vehicle Use","Cars","Lift Sharing"
244,"Transport","Reduced Vehicle Use","Bikes","Bike Conversion (electric)"
245,"Transport","Reduced Vehicle Use","Bikes","Bike Parking"
246,"Transport","Reduced Vehicle Use","Bikes","Bike Tracks"
243,"Transport","Reduced Vehicle Use","Bikes","Electric Bikes"
238,"Transport","Reduced Vehicle Use","Remote Working ","Local Work Spaces"
239,"Transport","Reduced Vehicle Use","Remote Working ","Video-conferencing"
241,"Transport","Reduced Vehicle Use","Walking","Walking Paths"
272,"Waste","Waste Avoidance","Reduce","Clothes Sharing"
273,"Waste","Waste Avoidance","Reduce","Food Boxes"
275,"Waste","Waste Avoidance","Reduce","Other Sharing Solutions"
274,"Waste","Waste Avoidance","Reduce","Tool / Equipment Sharing "
281,"Waste","Waste Avoidance","Repairing","Make Do & Mend "
282,"Waste","Waste Avoidance","Repairing","Other Repairing Solutions"
280,"Waste","Waste Avoidance","Repairing","Repair Cafe"
278,"Waste","Waste Avoidance","Reuse or Rehome","Clothing Bank"
277,"Waste","Waste Avoidance","Reuse or Rehome","Furniture Bank"
285,"Waste","Waste Processing","Recycling","Battery Recycling"
286,"Waste","Waste Processing","Recycling","Building Materials Recycling"
287,"Waste","Waste Processing","Recycling","Council Recycling Bank"
288,"Waste","Waste Processing","Recycling","Electrical/ Electronic Recycling"
289,"Waste","Waste Processing","Recycling","Food Recycling"
291,"Waste","Waste Processing","Recycling","Paper Recycling"
290,"Waste","Waste Processing","Recycling","Plastic Recycling "
292,"Waste","Waste Processing","Recycling","White Goods Recycling"
294,"Waste","Waste Processing","Rot","Community Composting"
295,"Waste","Waste Processing","Rot","Community Wormery"
Loading

0 comments on commit b49beaf

Please sign in to comment.