add

parent c0fe253d
...@@ -6,6 +6,7 @@ class CSVImporter ...@@ -6,6 +6,7 @@ class CSVImporter
NAME_DOMAIN = '192.168.1.156'.freeze NAME_DOMAIN = '192.168.1.156'.freeze
FTP_USERNAME = 'training'.freeze FTP_USERNAME = 'training'.freeze
FTP_PASSWORD = 'training'.freeze FTP_PASSWORD = 'training'.freeze
def initialize(logger) def initialize(logger)
@logger = logger @logger = logger
@extracting_directory = Rails.root.join('lib', 'csv') @extracting_directory = Rails.root.join('lib', 'csv')
...@@ -64,18 +65,14 @@ class CSVImporter ...@@ -64,18 +65,14 @@ class CSVImporter
industries_relationship = Industry.where(name: industry_name) industries_relationship = Industry.where(name: industry_name)
industry_job_relationship = IndustryJob.where(job_id: job.id, industry_id: industries_relationship.ids) industry_job_relationship = IndustryJob.where(job_id: job.id, industry_id: industries_relationship.ids)
if industry_job_relationship.blank? job.industries << industries_relationship if industry_job_relationship.blank?
job.industries << industries_relationship
end
location_data = row["work place"] location_data = row["work place"]
location = location_data.gsub('["', '').gsub('"]', '') location = location_data.gsub('["', '').gsub('"]', '')
location_relationship = City.where(name: location) location_relationship = City.where(name: location)
location_job_relationship = CityJob.where(job_id: job.id ,city_id: location_relationship.ids) location_job_relationship = CityJob.where(job_id: job.id ,city_id: location_relationship.ids)
if location_job_relationship.blank? job.cities << location_relationship if location_job_relationship.blank?
job.cities << location_relationship
end
rescue StandardError => e rescue StandardError => e
@logger.error e.message @logger.error e.message
......
...@@ -15,6 +15,7 @@ class JobParser ...@@ -15,6 +15,7 @@ class JobParser
links = info.css('div.caption a.company-name').map { |link| link['href'] } links = info.css('div.caption a.company-name').map { |link| link['href'] }
links.each do |link| links.each do |link|
next if link == 'javascript:void(0);' next if link == 'javascript:void(0);'
page = Nokogiri::HTML(URI.open(URI.escape(link))) page = Nokogiri::HTML(URI.open(URI.escape(link)))
name = page.search('p.name')&.text name = page.search('p.name')&.text
next if name.blank? next if name.blank?
......
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