change handle in controller to handle in model

parent f6afc562
Pipeline #796 failed with stages
in 0 seconds
class CitiesController < ApplicationController
def index
@cities_vietnam = City.all_city.where('location = 1')
@cities_international = City.all_city.where('location = 0')
@cities_vietnam = City.all_city.vietnam
@cities_international = City.all_city.international
end
end
......@@ -2,10 +2,11 @@ class City < ApplicationRecord
has_many :city_jobs
has_many :jobs, through: :city_jobs
scope :all_city, -> { joins(:jobs).group(:city_id).order('count(job_id) DESC') }
scope :vietnam, -> { where('location = 1') }
scope :international, -> { where('location = 0') }
def self.top_city
joins(:jobs).group(:city_id).order('count(job_id) DESC').limit(9)
end
def self.all_city
joins(:jobs).group(:city_id).order('count(job_id) DESC')
end
end
......@@ -15,6 +15,7 @@ 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
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