Commit f8e30777 by thanhnd

fix review 20200408 2

parent 2f8c9a9a
Pipeline #560 failed with stages
in 0 seconds
...@@ -6,22 +6,18 @@ class City < ApplicationRecord ...@@ -6,22 +6,18 @@ class City < ApplicationRecord
TOP_CITY_BY_JOB = 9 TOP_CITY_BY_JOB = 9
def self.top_cities_by_job def self.top_cities_by_job
#City.joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order.first(TOP_CITY_BY_JOB)
joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order.first(TOP_CITY_BY_JOB) joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order.first(TOP_CITY_BY_JOB)
end end
def self.top_cities_by_job_nn def self.top_cities_by_job_nn
#City.joins(:jobs).where("cities.area_id = 2").select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order.first(TOP_CITY_BY_JOB)
joins(:jobs).where("cities.area_id = 2").select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order.first(TOP_CITY_BY_JOB) joins(:jobs).where("cities.area_id = 2").select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order.first(TOP_CITY_BY_JOB)
end end
def self.all_cities_by_job def self.all_cities_by_job
#City.joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order
joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order
end end
def self.all_cities_by_job_nn def self.all_cities_by_job_nn
#City.joins(:jobs).where("cities.area_id = 2").select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order
joins(:jobs).where("cities.area_id = 2").select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order joins(:jobs).where("cities.area_id = 2").select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order
end end
......
...@@ -6,10 +6,10 @@ class Industry < ApplicationRecord ...@@ -6,10 +6,10 @@ class Industry < ApplicationRecord
TOP_INDUSTRY_BY_JOB = 9 TOP_INDUSTRY_BY_JOB = 9
def self.top_industries_by_job def self.top_industries_by_job
Industry.joins(:jobs).select('industries.*, COUNT(jobs.id) as job_count').group('jobs.industry_id').order(:job_count).last(TOP_INDUSTRY_BY_JOB) joins(:jobs).select('industries.*, COUNT(jobs.id) as job_count').group('jobs.industry_id').order(:job_count).last(TOP_INDUSTRY_BY_JOB)
end end
def self.all_industries_by_job def self.all_industries_by_job
Industry.joins(:jobs).select('industries.*, COUNT(jobs.id) as job_count').group('jobs.industry_id').order(:job_count).reverse_order joins(:jobs).select('industries.*, COUNT(jobs.id) as job_count').group('jobs.industry_id').order(:job_count).reverse_order
end end
end end
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