Commit 922638e8 by thanhnd

merge master to user_pages branch

parents 4374085f d436b357
about
action_mailbox:ingress:exim
action_mailbox:ingress:postfix
action_mailbox:ingress:qmail
action_mailbox:install
action_text:install
active_storage:install
app:template
app:update
assets:clean[keep]
assets:clobber
assets:environment
assets:precompile
autoprefixer:info
cache_digests:dependencies
cache_digests:nested_dependencies
db:create
db:drop
db:environment:set
db:fixtures:load
db:migrate
db:migrate:status
db:prepare
db:rollback
db:schema:cache:clear
db:schema:cache:dump
db:schema:dump
db:schema:load
db:seed
db:seed:replant
db:setup
db:structure:dump
db:structure:load
db:version
log:clear
middleware
restart
secret
stats
test
test:db
test:system
time:zones[country_or_offset]
tmp:clear
tmp:create
webpacker
webpacker:binstubs
webpacker:check_binstubs
webpacker:check_node
webpacker:check_yarn
webpacker:clean[keep]
webpacker:clobber
webpacker:compile
webpacker:info
webpacker:install
webpacker:install:angular
webpacker:install:coffee
webpacker:install:elm
webpacker:install:erb
webpacker:install:react
webpacker:install:stimulus
webpacker:install:svelte
webpacker:install:typescript
webpacker:install:vue
webpacker:verify_install
webpacker:yarn_install
yarn:install
zeitwerk:check
...@@ -67,3 +67,6 @@ gem 'kaminari-bootstrap' ...@@ -67,3 +67,6 @@ gem 'kaminari-bootstrap'
gem 'devise' gem 'devise'
gem 'bootstrap-sass' gem 'bootstrap-sass'
#setting file yml
gem 'settingslogic'
...@@ -198,6 +198,7 @@ GEM ...@@ -198,6 +198,7 @@ GEM
selenium-webdriver (3.142.7) selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0) childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2) rubyzip (>= 1.2.2)
settingslogic (2.0.9)
spring (2.1.0) spring (2.1.0)
spring-watcher-listen (2.0.1) spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0) listen (>= 2.7, < 4.0)
...@@ -260,6 +261,7 @@ DEPENDENCIES ...@@ -260,6 +261,7 @@ DEPENDENCIES
rails (~> 6.0.2, >= 6.0.2.1) rails (~> 6.0.2, >= 6.0.2.1)
sass-rails (>= 6) sass-rails (>= 6)
selenium-webdriver selenium-webdriver
settingslogic
spring spring
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)
sprockets (~> 3.7.2) sprockets (~> 3.7.2)
......
// Place all the styles related to the cities controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
// Place all the styles related to the industries controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
class CitiesController < ApplicationController class CitiesController < ApplicationController
def index def index
@top_cities_vn = City.top_city_by_job @top_cities_vn = City.top_cities_by_job
@top_cities_nn = City.top_city_by_job_nn @top_cities_nn = City.top_cities_by_job_nn
@all_cities_vn = City.all_city_by_job @all_cities_vn = City.all_cities_by_job
@all_cities_nn = City.all_city_by_job_nn @all_cities_nn = City.all_cities_by_job_nn
end end
end end
class IndustriesController < ApplicationController class IndustriesController < ApplicationController
def index def index
@all_industry = Industry.all_industry_by_job @top_industry = Industry.top_industries_by_job
end end
end end
class JobsController < ApplicationController class JobsController < ApplicationController
def show def show
@job_detail = Job.find(params[:id]) @job_detail = Job.find_by_id(params[:id])
end end
def index def index
@job_list = Job.all
@job_count = Job.count @job_count = Job.count
@pagin_job = Job.page(params[:page]).per(20) pagin = params[:page].to_i > 0 ? params[:page].to_i : 1
@pagin_job = Job.page(pagin).per(Settings.page)
end end
def search def search
if params[:search].nil? return redirect_to root_path, alert: "Empty field!" if params[:search].blank?
redirect_to(root_path, alert: "Empty field!") and return
else
@job_count = Job.count
@search_job = Job.where("job_name LIKE '%#{params[:search]}%'")
@pagin_job = @search_job.page(params[:page]).per(20)
end
render :index
end
@search_job = Job.includes(:city).where("job_name LIKE ?","%#{params[:search]}%")
@pagin_job = @search_job.page(params[:page]).per(Settings.page)
end
end end
...@@ -2,8 +2,8 @@ class TopPageController < ApplicationController ...@@ -2,8 +2,8 @@ class TopPageController < ApplicationController
def index def index
@total_jobs = Job.count @total_jobs = Job.count
@latest_jobs = Job.latest_job @latest_jobs = Job.latest_job
@top_industries = Industry.top_industry_by_job @top_industries = Industry.top_industries_by_job
@top_cities = City.top_city_by_job @top_cities = City.top_cities_by_job
end end
end end
......
...@@ -2,9 +2,23 @@ class City < ApplicationRecord ...@@ -2,9 +2,23 @@ class City < ApplicationRecord
belongs_to :area belongs_to :area
has_many :jobs has_many :jobs
validates_presence_of :city_name validates_presence_of :city_name
scope :top_city_by_job, ->{joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order.first(9)}
scope :top_city_by_job_nn, ->{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(9)}
scope :all_city_by_job, ->{joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order} TOP_CITY_BY_JOB = 9
scope :all_city_by_job_nn, ->{joins(:jobs).where("cities.area_id = 2").select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order}
def self.top_cities_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
def self.top_cities_by_job_nn
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
def self.all_cities_by_job
joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order
end
def self.all_cities_by_job_nn
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 end
...@@ -2,6 +2,14 @@ class Industry < ApplicationRecord ...@@ -2,6 +2,14 @@ class Industry < ApplicationRecord
has_many :industry_jobs has_many :industry_jobs
has_many :jobs has_many :jobs
validates_presence_of :industry_name validates_presence_of :industry_name
scope :top_industry_by_job, ->{joins(:jobs).select('industries.*, COUNT(jobs.id) as job_count').group('jobs.industry_id').order(:job_count).last(9)}
scope :all_industry_by_job, ->{joins(:jobs).select('industries.*, COUNT(jobs.id) as job_count').group('jobs.industry_id').order(:job_count).reverse_order} TOP_INDUSTRY_BY_JOB = 9
def self.top_industries_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
def self.all_industries_by_job
joins(:jobs).select('industries.*, COUNT(jobs.id) as job_count').group('jobs.industry_id').order(:job_count).reverse_order
end
end end
class Settings < Settingslogic
source "#{Rails.root}/config/setting.yml"
namespace Rails.env
end
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<div id="topcity_vn" class="container p-5 my-2 bg-secondary text-white"> <div id="topcity_vn" class="container p-5 my-2 bg-secondary text-white">
<font color="red"><b><label > Viet Nam:</label></b></font> <font color="red"><b><label > Viet Nam:</label></b></font>
<% @all_cities_vn.each do |city_vn| %> <% @top_cities_vn.each do |city_vn| %>
<ul> <ul>
<li><%= city_vn.city_name %> <br /> Total jobs in this city: <%= city_vn.job_count %> </li> <li><%= city_vn.city_name %> <br /> Total jobs in this city: <%= city_vn.job_count %> </li>
</ul> </ul>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<div id="topcity_nn" class="container p-5 my-2 bg-secondary text-white"> <div id="topcity_nn" class="container p-5 my-2 bg-secondary text-white">
<font color="red"><b><label > Nuoc Ngoai:</label></b></font> <font color="red"><b><label > Nuoc Ngoai:</label></b></font>
<% @all_cities_nn.each do |city_nn| %> <% @top_cities_nn.each do |city_nn| %>
<ul> <ul>
<li><%= city_nn.city_name %> <br /> Total jobs in this city: <%= city_nn.job_count %> </li> <li><%= city_nn.city_name %> <br /> Total jobs in this city: <%= city_nn.job_count %> </li>
</ul> </ul>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<div id="industry_list" class="container p-5 my-2 bg-secondary text-white"> <div id="industry_list" class="container p-5 my-2 bg-secondary text-white">
<font color="red"><b><label > Industry List:</label></b></font> <font color="red"><b><label > Industry List:</label></b></font>
<% @all_industry.each do |industry| %> <% @top_industry.each do |industry| %>
<ul> <ul>
<li><%= industry.industry_name %> <br /> Total jobs in this industry: <%= industry.job_count %> </li> <li><%= industry.industry_name %> <br /> Total jobs in this industry: <%= industry.job_count %> </li>
</ul> </ul>
......
<font color="red"><b><label > Job List:</label></b></font>
<%= paginate @pagin_job %>
<% @pagin_job.each do |job| %>
<ul>
<button class="button button2">Favorites</button>
<li><%= job.job_name %></li>
<li><%= job.city.city_name %></li>
<li ><span class="text"><%= job.description %></span></li>
</ul>
<% end %>
<%= paginate @pagin_job %>
...@@ -13,21 +13,10 @@ ...@@ -13,21 +13,10 @@
<div id="job_list" class="container p-5 my-2 bg-secondary text-white"> <div id="job_list" class="container p-5 my-2 bg-secondary text-white">
<div class="total_job"> <div class="total_job">
<label> Total Jobs: <%= @job_count %></label> <label> Total Jobs: <%= Job.count %></label>
</div> </div>
<font color="red"><b><label > Job List:</label></b></font> <%= render partial: "jobs"%>
<%= paginate @pagin_job %>
<% @pagin_job.each do |job| %>
<ul>
<button class="button button2">Favorites</button>
<li><%= job.job_name %></li>
<li><%= job.city.city_name %></li>
<li ><span class="text"><%= job.description %></span></li>
</ul>
<% end %>
<%= paginate @pagin_job %>
</div> </div>
......
...@@ -10,18 +10,5 @@ ...@@ -10,18 +10,5 @@
<div id="job_list" class="container p-5 my-2 bg-secondary text-white"> <div id="job_list" class="container p-5 my-2 bg-secondary text-white">
<%= render partial: "jobs" %>
<font color="red"><b><label > Job List:</label></b></font>
<%= paginate @pagin_job %>
<% @pagin_job.each do |job| %>
<ul>
<button class="button button2">Favorites</button>
<li><%= job.job_name %></li>
<li><%= job.city.city_name %></li>
<li ><span class="text"><%= job.description %></span></li>
</ul>
<% end %>
<%= paginate @pagin_job %>
</div> </div>
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search"> <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-warning btn-rounded btn-sm my-0" type="submit">Search</button> <button class="btn btn-outline-warning btn-rounded btn-sm my-0" type="submit">Search</button>
</form> </form>
</div> </div>
<div id="job_detail"class="container p-5 my-2 bg-secondary text-white"> <div id="job_detail"class="container p-5 my-2 bg-secondary text-white">
<% if @job_detail.nil? == true %>
<div> This id is not available. </div>
<% else %>
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><a href="#">Top</a></li> <li><a href="#">Top</a></li>
<li><a href="#">City</a></li> <li><a href="#">City</a></li>
...@@ -16,7 +19,6 @@ ...@@ -16,7 +19,6 @@
<li><%= @job_detail.job_name %></li> <li><%= @job_detail.job_name %></li>
</ul> </ul>
<font color="red"><b><label > Job Detail:</label></b></font> <font color="red"><b><label > Job Detail:</label></b></font>
<ul> <ul>
<li><%= @job_detail.job_name %></li> <li><%= @job_detail.job_name %></li>
...@@ -26,10 +28,9 @@ ...@@ -26,10 +28,9 @@
<li ><span class="text"><%= @job_detail.description %></span> <li ><span class="text"><%= @job_detail.description %></span>
</li> </li>
</ul> </ul>
<button class="button button1">Apply</button> <button class="button button1">Apply</button>
<button class="button button2">Favorites</button> <button class="button button2">Favorites</button>
<% end %>
</div> </div>
......
...@@ -2,3 +2,5 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) ...@@ -2,3 +2,5 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile. require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations. require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
require 'yaml'
#YAML::ENGINE.yamler= 'syck'
Rails.application.routes.draw do Rails.application.routes.draw do
get 'detail/:id', to: 'jobs#show'
get 'jobs', to: 'jobs#index' get 'jobs', to: 'jobs#index'
get 'cities', to: 'cities#index' resources :cities, only: [:index]
get 'industries', to: 'industries#index' resources :industries, only: [:index]
get 'jobs/search' => 'jobs#search', as: :job_search
devise_for :users devise_for :users
as :user do as :user do
...@@ -14,6 +10,10 @@ Rails.application.routes.draw do ...@@ -14,6 +10,10 @@ Rails.application.routes.draw do
delete "signout" => "devise/sessions#destroy" delete "signout" => "devise/sessions#destroy"
end end
#get 'jobs', to: 'jobs#index'
resources :jobs, only: [:index]
get 'detail/:id', to: 'jobs#show'
get 'jobs/search' => 'jobs#search', as: :job_search
root 'top_page#index' root 'top_page#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :top_page resources :top_page
......
...@@ -29,6 +29,8 @@ development: ...@@ -29,6 +29,8 @@ development:
<<: *defaults <<: *defaults
web_url: 'localhost:3000' web_url: 'localhost:3000'
kuruma_host: 'http://kuruma-ex.dev' kuruma_host: 'http://kuruma-ex.dev'
page: 5
test: test:
<<: *defaults <<: *defaults
......
require 'test_helper'
class IndustriesControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get industries_index_url
assert_response :success
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