-
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 all 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,12 @@ class BaseImporter | |
attr_reader :file, :import_results | ||
attr_accessor :override_id | ||
|
||
def initialize(file) | ||
# @param file [File] | ||
# @param options [Hash] | ||
# @option override_id [Boolean] override automatic ids and make use of id in the import data | ||
def initialize(file, options = {}) | ||
@file = file | ||
@override_id = options[:override_id] if options[:override_id] | ||
end | ||
|
||
def call | ||
|
@@ -17,6 +21,7 @@ def call | |
|
||
ActiveRecord::Base.transaction(requires_new: true) do | ||
import | ||
reset_id_seq if override_id | ||
raise ActiveRecord::Rollback if errors.any? | ||
end | ||
|
||
|
@@ -60,6 +65,12 @@ def csv_converters | |
|
||
private | ||
|
||
def reset_id_seq | ||
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. 👍 |
||
table_name = resource_klass.table_name | ||
seq_name = "#{table_name}_id_seq" | ||
ActiveRecord::Base.connection.execute("select setval('#{seq_name}', max(id)) from #{table_name};") | ||
end | ||
|
||
def reset_import_results | ||
@import_results = { | ||
new_records: 0, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,9 +41,9 @@ def prepare_assessment(row) | |
end | ||
|
||
def find_company!(row) | ||
return unless row[:company].present? | ||
return unless row[:company_id].present? | ||
|
||
Company.where('lower(name) = ?', row[:company].downcase).first! | ||
Company.find(row[:company_id]) | ||
end | ||
|
||
def assessment_attributes(row) | ||
|
@@ -52,7 +52,8 @@ def assessment_attributes(row) | |
publication_date: publication_date(row), | ||
level: row[:level], | ||
notes: row[:notes], | ||
questions: get_questions(row) | ||
questions: get_questions(row), | ||
methodology_version: row[:methodology_version] | ||
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. 👍 |
||
} | ||
end | ||
|
||
|
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 |
5 changes: 5 additions & 0 deletions
5
db/migrate/20191122133323_add_methodology_version_to_mq_assessments.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 AddMethodologyVersionToMQAssessments < ActiveRecord::Migration[6.0] | ||
def change | ||
add_column :mq_assessments, :methodology_version, :integer | ||
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
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 😅