Commit 28ad2bf6 by Tô Ngọc Ánh

refactor code

parent 03ee3000
Pipeline #754 canceled with stages
in 0 seconds
class Industry < ApplicationRecord class Industry < ApplicationRecord
scope :top_industries, ->(number) { joins(:jobs).group(:industry_id).order(Arel.sql('count(jobs.id) DESC')).take(number) } scope :top_industries, ->(number) { joins(:jobs)
.group(:industry_id)
.order(Arel.sql('count(jobs.id) DESC'))
.take(number) }
has_and_belongs_to_many :jobs has_and_belongs_to_many :jobs
end end
class Location < ApplicationRecord class Location < ApplicationRecord
scope :top_locations, ->(number) { joins(:jobs).group(:location_id).order(Arel.sql('count(jobs.id) DESC')).take(number) } scope :top_locations, ->(number) { joins(:jobs)
.group(:location_id)
.order(Arel.sql('count(jobs.id) DESC'))
.take(number) }
CITY_VIETNAM_NUMBER = 70 CITY_VIETNAM_NUMBER = 70
......
...@@ -11,19 +11,19 @@ ...@@ -11,19 +11,19 @@
<div class='row'> <div class='row'>
<%= render partial: 'home/job', collection: @jobs %> <%= render partial: 'home/job', collection: @jobs %>
</div> </div>
<a href='#'>See more...</a> <a href='#'>All jobs</a>
</div> </div>
<div id='top-city' class='my-4 text-center'> <div id='top-city' class='my-4 text-center'>
<h1>Top Cities</h1> <h1>Top Cities</h1>
<div class='row'> <div class='row'>
<%= render partial: 'home/city', collection: @top_cities, as: :location %> <%= render partial: 'home/city', collection: @top_cities, as: :location %>
</div> </div>
<a href='#'>See more...</a> <a href='#'>All Cities</a>
</div> </div>
<div id='top-industry' class='my-4 text-center'> <div id='top-industry' class='my-4 text-center'>
<h1>Top Industries</h1> <h1>Top Industries</h1>
<div class='row'> <div class='row'>
<%= render partial: 'home/industry', collection: @top_industries, as: :industry %> <%= render partial: 'home/industry', collection: @top_industries, as: :industry %>
</div> </div>
<a href='#'>See more...</a> <a href='#'>All Industries</a>
</div> </div>
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head> </head>
<body class="container"> <body class='container'>
<%= render 'shared/navbar' %> <%= render 'shared/header' %>
<%= yield %> <%= yield %>
<%= render 'shared/footer' %> <%= render 'shared/footer' %>
</body> </body>
......
...@@ -3,7 +3,7 @@ require './lib/common/csv' ...@@ -3,7 +3,7 @@ require './lib/common/csv'
require './lib/common/crawler' require './lib/common/crawler'
namespace :import_data do namespace :import_data do
logger ||= Logger.new('./log/import_data.log') logger = Logger.new('./log/import_data.log')
desc 'crawl industries locations jobs' desc 'crawl industries locations jobs'
task :crawler, %i[page_number link] => [:environment] do |_, args| task :crawler, %i[page_number link] => [:environment] do |_, args|
......
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