-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TPI Production Ready Seeds #131
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3335856
Adds instrument types and instruments
simaob e581d9a
Import sectors in the seeds
simaob 8e24c0d
adds sorting
simaob 3fe6918
Adds updated companies migration file and updates as needed
simaob 35123b4
Adds CP benchmarks
simaob 1d7c84e
Update some ids
simaob 5d64279
Updates cp_assessments and mq_assessments importers to use company id…
simaob 0718613
Updates files and small fix for when there's no assessment_date for a…
simaob 6aeedb9
updates to specs e fixes do rubocop
simaob 65875c0
ISIN is no longer unique
simaob 4321ecc
Include company id in cp and mq assessments download
simaob 8109cb8
refactors to have override_id passed as an option
simaob 3b40d1e
Adds methodology_version to MQ::Assessment
simaob d89edcc
Update assessment date format to use hifens
simaob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
db/migrate/20191121170141_remove_isin_index_from_companies.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class RemoveIsinIndexFromCompanies < ActiveRecord::Migration[6.0] | ||
def change | ||
remove_index :companies, :isin | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,60 @@ | |
sector.update!(cp_unit: sector_cp_unit) if sector.new_record? && sector_cp_unit.present? | ||
end | ||
|
||
# instruments: Instrument Type & Instrument | ||
# envs: ALL | ||
# rubocop:disable Style/WordArray | ||
[ | ||
['Capacity-building', ['Knowledge generation', | ||
'Sharing and dissemination', | ||
'Research and development', | ||
'Education and training']], | ||
['Regulation', ['Standards and obligations', | ||
'Building codes', | ||
'Zoning and spatial planning', | ||
'Disclosure obligations']], | ||
['Incentives', ['Taxes', 'Subsidies']], | ||
['Governance and planning', ['Creating bodies/institutions', | ||
'Designing processes', | ||
'Developing plans and strategies', | ||
'Assigning responsibilities to other levels of government', | ||
'Monitoring and evaluation']], | ||
['Direct investment', ['Public goods - early warning systems', | ||
'Public goods - other', | ||
'Social safety nets', | ||
'Provision of climate finance']] | ||
].each do |inst_type, instruments| | ||
type = InstrumentType.find_or_create_by!(name: inst_type) | ||
instruments.each do |inst| | ||
Instrument.find_or_create_by!(name: inst, instrument_type: type) | ||
end | ||
end | ||
# rubocop:enable Style/WordArray | ||
|
||
# Laws sectors: Names | ||
# envs: ALL | ||
[ | ||
'Agriculture', | ||
'Residential and Commercial', | ||
'Coastal zones', | ||
'Economy-wide', | ||
'Energy', | ||
'Health', | ||
'Industry', | ||
'LULUCF', | ||
'Social development', | ||
'Tourism', | ||
'Transportation', | ||
'Urban', | ||
'Waste', | ||
'Water', | ||
'Rural', | ||
'Environment', | ||
'Other' | ||
].each do |sector| | ||
LawsSector.find_or_create_by!(name: sector) | ||
end | ||
|
||
if Rails.env.development? || ENV['SEED_DATA'] | ||
# import geographies | ||
TimedLogger.log('Import geographies') do | ||
|
@@ -37,8 +91,12 @@ | |
|
||
# import companies | ||
TimedLogger.log('Import companies') do | ||
file = File.open(Rails.root.join('db', 'seeds', 'companies.csv'), 'r') | ||
CSVImport::Companies.new(file).call | ||
file = File.open(Rails.root.join('db', 'seeds', 'tpi-companies.csv'), 'r') | ||
importer = CSVImport::Companies.new(file) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just taking a note here (not a blocker for this PR) to refactor this just a little |
||
importer.override_id = true | ||
importer.call | ||
|
||
ActiveRecord::Base.connection.execute("select setval('companies_id_seq',max(id)) from companies;") | ||
end | ||
|
||
# import CP Benchmarks | ||
|
@@ -60,6 +118,9 @@ | |
|
||
file = File.open(Rails.root.join('db', 'seeds', 'mq-assessments-M2.csv'), 'r') | ||
CSVImport::MQAssessments.new(file).call | ||
|
||
file = File.open(Rails.root.join('db', 'seeds', 'mq-assessments-M3.csv'), 'r') | ||
CSVImport::MQAssessments.new(file).call | ||
end | ||
|
||
# import Legislations | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, I missed that thing before, but that wasn't right after having multiple ISINs in one string ;]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I missed that too 😅