add

parent c0fe253d
......@@ -6,6 +6,7 @@ class CSVImporter
NAME_DOMAIN = '192.168.1.156'.freeze
FTP_USERNAME = 'training'.freeze
FTP_PASSWORD = 'training'.freeze
def initialize(logger)
@logger = logger
@extracting_directory = Rails.root.join('lib', 'csv')
......@@ -55,27 +56,23 @@ class CSVImporter
salary = row["salary"]
job = Job.find_or_create_by!(title: title_job,
description: description_job,
level: level,
salary: salary,
company_id: company.id)
description: description_job,
level: level,
salary: salary,
company_id: company.id)
industry_name = row["category"]
industries_relationship = Industry.where(name: industry_name)
industry_job_relationship = IndustryJob.where(job_id: job.id, industry_id: industries_relationship.ids)
if industry_job_relationship.blank?
job.industries << industries_relationship
end
job.industries << industries_relationship if industry_job_relationship.blank?
location_data = row["work place"]
location = location_data.gsub('["', '').gsub('"]', '')
location_relationship = City.where(name: location)
location_job_relationship = CityJob.where(job_id: job.id ,city_id: location_relationship.ids)
if location_job_relationship.blank?
job.cities << location_relationship
end
job.cities << location_relationship if location_job_relationship.blank?
rescue StandardError => e
@logger.error e.message
......
......@@ -15,8 +15,9 @@ class JobParser
links = info.css('div.caption a.company-name').map { |link| link['href'] }
links.each do |link|
next if link == 'javascript:void(0);'
page = Nokogiri::HTML(URI.open(URI.escape(link)))
name = page.search('p.name')&.text
page = Nokogiri::HTML(URI.open(URI.escape(link)))
name = page.search('p.name')&.text
next if name.blank?
address = page.css('div.content p').children[1]&.text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment