-
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
Feature/enable multiple isins #31
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,4 +48,8 @@ def latest_assessment | |
def to_s | ||
name | ||
end | ||
|
||
def isin_string | ||
isin.split(',') | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,14 @@ def call | |
|
||
def import | ||
import_each_with_logging(csv, FILEPATH) do |row| | ||
company = Company.find_or_initialize_by(isin: row[:isin]) | ||
company = Company.find_or_initialize_by(name: row[:company_name]) | ||
|
||
company.isin = if company.isin.present? | ||
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. couldn't this be moved to 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. probably so. I kept it here, but it doesn't make so much sense now. I'll move it. 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. hmmm, actually, I would need to pass the current isin to that method if I were to manage this there. Currently the |
||
(company.isin.split(',') + [row[:isin]]).uniq.join(',') | ||
else | ||
row[:isin] | ||
end | ||
|
||
company.update!(company_attributes(row)) | ||
|
||
create_mq_assessment!(row, company) | ||
|
@@ -28,6 +35,7 @@ def import | |
def cleanup | ||
MQ::Assessment.destroy_all | ||
CP::Assessment.destroy_all | ||
Company.destroy_all | ||
end | ||
|
||
def csv | ||
|
@@ -67,7 +75,6 @@ def company_attributes(row) | |
geography = Import::GeographyUtils.find_by_iso(fix_iso(row[:country_code])) | ||
|
||
{ | ||
name: row[:company_name], | ||
ca100: row[:ca100_company?] == 'Yes', | ||
geography: geography, | ||
headquarters_geography: geography, | ||
|
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.
I think this belongs to
CompanyDecorator
which needs to be created :)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.
also, this name is a bit confusing - this returns an array.
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.
you're right! I've moved the method to a new decorator, and I've renamed it to
isin_as_tags
. 🙇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.
👍