Commit 011ac89c by thanhnd

Merge branch 'master' into 'user_pages'

# Conflicts:
#   Gemfile
#   config/routes.rb
#   config/setting.yml
parents 4374085f 6a010474
Pipeline #562 failed with stages
in 0 seconds
......@@ -198,6 +198,7 @@ GEM
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
settingslogic (2.0.9)
spring (2.1.0)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
......@@ -260,6 +261,7 @@ DEPENDENCIES
rails (~> 6.0.2, >= 6.0.2.1)
sass-rails (>= 6)
selenium-webdriver
settingslogic
spring
spring-watcher-listen (~> 2.0.0)
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
def index
@top_cities_vn = City.top_city_by_job
@top_cities_nn = City.top_city_by_job_nn
@all_cities_vn = City.all_city_by_job
@all_cities_nn = City.all_city_by_job_nn
@top_cities_vn = City.top_cities_by_job
@top_cities_nn = City.top_cities_by_job_nn
@all_cities_vn = City.all_cities_by_job
@all_cities_nn = City.all_cities_by_job_nn
end
end
class IndustriesController < ApplicationController
def index
@all_industry = Industry.all_industry_by_job
@top_industry = Industry.top_industries_by_job
end
end
class JobsController < ApplicationController
def show
@job_detail = Job.find(params[:id])
@job_detail = Job.find_by_id(params[:id])
end
def index
@job_list = Job.all
@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
def search
if params[:search].nil?
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
return redirect_to root_path, alert: "Empty field!" if params[:search].blank?
@search_job = Job.includes(:city).where("job_name LIKE ?","%#{params[:search]}%")
@pagin_job = @search_job.page(params[:page]).per(Settings.page)
end
end
......@@ -2,9 +2,23 @@ class City < ApplicationRecord
belongs_to :area
has_many :jobs
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)}
TOP_CITY_BY_JOB = 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}
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
......@@ -2,6 +2,14 @@ class Industry < ApplicationRecord
has_many :industry_jobs
has_many :jobs
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
class Settings < Settingslogic
source "#{Rails.root}/config/setting.yml"
namespace Rails.env
end
......@@ -18,7 +18,7 @@
<div id="topcity_vn" class="container p-5 my-2 bg-secondary text-white">
<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>
<li><%= city_vn.city_name %> <br /> Total jobs in this city: <%= city_vn.job_count %> </li>
</ul>
......@@ -28,7 +28,7 @@
<div id="topcity_nn" class="container p-5 my-2 bg-secondary text-white">
<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>
<li><%= city_nn.city_name %> <br /> Total jobs in this city: <%= city_nn.job_count %> </li>
</ul>
......
......@@ -11,7 +11,7 @@
<div id="industry_list" class="container p-5 my-2 bg-secondary text-white">
<font color="red"><b><label > Industry List:</label></b></font>
<% @all_industry.each do |industry| %>
<% @top_industry.each do |industry| %>
<ul>
<li><%= industry.industry_name %> <br /> Total jobs in this industry: <%= industry.job_count %> </li>
</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 @@
<div id="job_list" class="container p-5 my-2 bg-secondary text-white">
<div class="total_job">
<label> Total Jobs: <%= @job_count %></label>
<label> Total Jobs: <%= Job.count %></label>
</div>
<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 %>
<%= render partial: "jobs"%>
</div>
......
......@@ -10,18 +10,5 @@
<div id="job_list" class="container p-5 my-2 bg-secondary text-white">
<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 %>
<%= render partial: "jobs" %>
</div>
......@@ -5,10 +5,13 @@
<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>
</form>
</div>
<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">
<li><a href="#">Top</a></li>
<li><a href="#">City</a></li>
......@@ -16,7 +19,6 @@
<li><%= @job_detail.job_name %></li>
</ul>
<font color="red"><b><label > Job Detail:</label></b></font>
<ul>
<li><%= @job_detail.job_name %></li>
......@@ -26,10 +28,9 @@
<li ><span class="text"><%= @job_detail.description %></span>
</li>
</ul>
<button class="button button1">Apply</button>
<button class="button button2">Favorites</button>
<% end %>
</div>
......
......@@ -2,3 +2,5 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
require 'yaml'
#YAML::ENGINE.yamler= 'syck'
......@@ -14,6 +14,10 @@ Rails.application.routes.draw do
delete "signout" => "devise/sessions#destroy"
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'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :top_page
......
defaults: &defaults
ga_tracking_id: 'UA-2260154-19'
cookies:
expiration_time: 90
inquiry:
account_test:
name_words:
- 'じげん'
- '次元'
- 'jigexn'
- 'zigexn'
- 'zigen'
- 'ジゲン'
mail_word: zigexn
ips:
- 118.69.34.46
- 14.161.45.187
- 39.110.206.184
- 39.110.241.117
mailer:
inquiry:
bcc:
- 'p-kuruma-ex+dev@zigexn.vn'
er: 220
development:
<<: *defaults
web_url: 'localhost:3000'
kuruma_host: 'http://kuruma-ex.dev'
test:
<<: *defaults
web_url: 'localhost:3000'
chukosya_host: 'http://staging.chukosya-ex.jp'
staging:
<<: *defaults
web_url: 'kuruma-ex-stg.zigexn.vn'
chukosya_host: 'http://staging.chukosya-ex.jp'
production:
<<: *defaults
web_url: 'kuruma-ex.jp'
page: 5
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