Commit 34e7d4fe by nnnghia98

order city on top page

parent 3aa0194a
class TopsController < ApplicationController class TopsController < ApplicationController
def index def index
@vn_cities = City.vn_cities @vn_cities = City.city_order.take(Settings.top.city.limit)
@industries = Industry.all @industries = Industry.all
@jobs = Job.page(params[:page]).per(Settings.job.per_page) @jobs = Job.page(params[:page]).per(Settings.job.per_page)
end end
......
...@@ -23,4 +23,8 @@ class City < ApplicationRecord ...@@ -23,4 +23,8 @@ class City < ApplicationRecord
def job_count def job_count
@job_count ||= jobs.count @job_count ||= jobs.count
end end
def self.city_order
@city_order ||= all.sort_by(&:job_count).reverse
end
end end
...@@ -3,3 +3,7 @@ job: ...@@ -3,3 +3,7 @@ job:
csv: csv:
file_path: "jobss.csv" file_path: "jobss.csv"
top:
city:
limit: 9
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