Commit d04c9f2f by Thanh Hung Pham

Fix import categories and cities

parent e3fd63c3
......@@ -128,7 +128,7 @@ class Careerbuilder
def import_category(doc)
categories = doc.xpath("//div[@class='s-home2']/div[@id='NewSearchJob3']/form/div[@class='search-horizontal']/div[@class='ui-widget box_multiSelect_industry']/select/option")
categories = categories.slice(1..categories.size - 2)
categories = categories.drop(1)
categories.each do |category|
Category.new(name: category.text.strip).save if Category.where(name: category.text.strip).blank?
end
......@@ -140,10 +140,10 @@ class Careerbuilder
def import_city(doc)
cities = doc.xpath("//div[@class='s-home2']//div[@id='NewSearchJob3']/form/div[@class='search-horizontal']/div[@class='ui-widget box_multiSelect_location']/select/option").drop(1)
area_id = 1
area = Area.find_by_name('Viet Nam')
cities.each do |city|
area_id = 2 if city.text == 'Angola'
City.new(name: city.text.strip, area: Area.find(area_id)).save if City.where(name: city.text.strip).blank?
area = Area.find_by_name('International') if city.text == 'Angola'
City.new(name: city.text.strip, area: area).save if City.where(name: city.text.strip).blank?
end
rescue StandardError => e
logger.error("[method: ] #{import_city}")
......
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