Commit 56be2f14 by Hoang Nam Nguyen

'Fix Top,industry,city_pages'

parent c4db0830
......@@ -11,6 +11,8 @@ gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.
gem 'nokogiri'
gem 'whenever', :require => false
gem "figaro"
gem 'counter_culture', '~> 0.1.33'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.3'
# Use mysql as the database for Active Record
......
......@@ -40,6 +40,9 @@ GEM
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
after_commit_action (1.0.1)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
arel (8.0.0)
bindex (0.5.0)
bootstrap-will_paginate (1.0.0)
......@@ -65,9 +68,15 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
counter_culture (0.1.34)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
after_commit_action (~> 1.0.0)
erubi (1.6.1)
execjs (2.7.0)
ffi (1.9.18)
figaro (1.1.1)
thor (~> 0.14)
globalid (0.4.0)
activesupport (>= 4.2.0)
i18n (0.8.6)
......@@ -196,6 +205,8 @@ DEPENDENCIES
byebug
capybara (~> 2.13)
coffee-rails (~> 4.2)
counter_culture (~> 0.1.33)
figaro
jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2)
mysql2 (>= 0.3.18, < 0.5)
......
......@@ -4,18 +4,17 @@
}
#distance {
border-width: 3px;
margin-top: 5px;
width: 120px;
margin-top: 10%;
width: 130%;
border-radius: 25px;
}
#slidebar {
padding-right: 100px;
padding-right: 5%;
}
#slide {
padding-left: 600px;
padding-left: 32%;
}
.container-fluid {
......@@ -35,58 +34,53 @@ input[type=text]:focus {
}
#image_height {
padding-left: 5px;
width: 99.5%;
}
#fontwords {
margin-top: 30px;
padding-left: 341px;
margin-top: 5%;
padding-left: 34%
}
#search_button {
margin-top: 30px;
margin-left: 50px;
margin-left: 3%;
}
#search_box {
width: 1000px;
width: 88%;
margin-top: 30px;
}
.line_job {
margin-left: -190px;
margin-top: 30px;
font-size: 35px;
margin-left: -17%;
margin-top: 5%;
font-size: 220%;
}
.jobs {
margin-top: 20px;
width: 10000px;
margin-left: 11px;
width: 125%;
margin-left: 2.5%;
}
.detail_description {
font-size: 13px;
font-size: 80%;
}
.cities {
margin-top: 10px;
margin-left: 10px;
width: 1126px;
margin-left: 2%;
border: 1px solid rgba(0, 0, 0, 0.125);
}
.titlejob{
width: 1116px;
margin-left: -2px;
height: 550px;
width: 50%;
margin-left: -3%;
}
.total_jobs {
margin-top: -10px;
margin-bottom: 5px;
font-size: 14px;
font-size: 80%;
margin-left: 30%;
margin-top: -5%;
}
.column_set {
......@@ -94,14 +88,24 @@ input[type=text]:focus {
}
#cities_button {
margin-left: 955px;
margin-bottom: 37px;
margin-top: 30px;
margin-left: 83%;
margin-bottom: 3%;
margin-top: 3%;
}
#industries_button{
margin-bottom: 3%;
margin-top: 3%;
margin-left: 89.7%;
}
.content_job {
margin-top: -1.5%;
}
.name_list_top {
margin-left: 30%;
margin-top: 5%;
}
/* city list */
#international_city {
......
class TopPagesController < ApplicationController
def cities
@vn_cities = City.where(location: City::VN_CITIES)
@international_cities = City.where('location NOT IN (?)', City::VN_CITIES)
@vn_cities = City.where(is_vietnam: true)
@international_cities = City.where(is_vietnam: false)
end
def industries
@industries_page = Industry.order(industry_name: :desc).all
end
def jobs
end
def top_page
@jobs = Job.order(short_description: :desc, job_title: :desc,salary: :desc).limit(5)
@jobs = Job.order(short_description: :desc, job_title: :desc,salary: :desc).limit(ENV["Number_top_page_jobs"])
@total_job = Job.count
@industries = Industry.limit(9)
@cities = City.limit(9)
@industries = Industry.limit(ENV["Number_top_page"])
@cities = City.limit(ENV["Number_top_page"])
end
def show
......
class City < ApplicationRecord
has_many :job_cities
has_many :jobs, through: :job_cities
VN_CITIES = ["Hà Nội",
"Hồ Chí Minh",
"An Giang",
"Bà Rịa - Vũng Tàu",
"Bạc Liêu",
"Bắc Cạn",
"Bắc Giang",
"Bắc Ninh",
"Bến Tre",
"Bình Dương",
"Bình Định",
"Bình Phước",
"Bình Thuận",
"Cà Mau",
"Cao Bằng",
"Cần Thơ",
"Dak Lak",
"Dak Nông",
"Đà Nẵng",
"Điện Biên",
"Đồng Bằng Sông Cửu Long",
"Đồng Nai",
"Đồng Tháp",
"Gia Lai",
"Hà Giang",
"Hà Nam",
"Hà Tây",
"Hà Tĩnh",
"Hải Dương",
"Hải Phòng",
"Hậu Giang",
"Hòa Bình",
"Hưng Yên",
"Khác",
"Khánh Hòa",
"Kiên Giang",
"Kon Tum",
"KV Bắc Trung Bộ",
"KV Đông Nam Bộ",
"KV Nam Trung Bộ",
"KV Tây Nguyên",
"Lai Châu",
"Lạng Sơn",
"Lào Cai",
"Lâm Đồng",
"Long An",
"Nam Định",
"Nghệ An",
"Ninh Bình",
"Ninh Thuận",
"Phú Thọ",
"Phú Yên",
"Quảng Bình",
"Quảng Nam",
"Quảng Ngãi",
"Quảng Ninh",
"Quảng Trị",
"Sóc Trăng",
"Sơn La",
"Tây Ninh",
"Thái Bình",
"Thái Nguyên",
"Thanh Hóa",
"Thừa Thiên- Huế",
"Tiền Giang",
"Toàn quốc",
"Trà Vinh",
"Tuyên Quang",
"Vĩnh Long",
"Vĩnh Phúc",
"Yên Bái",
"Đắk Nông",
"Xã Xuân Giao",
"Thừa Thiên Huế",
"Đắk Lắk"]
end
class JobCity < ApplicationRecord
belongs_to :job
belongs_to :city
belongs_to :city, counter_cache: true
end
class JobIndustry < ApplicationRecord
belongs_to :job
belongs_to :industry
belongs_to :industry, counter_cache: true
end
<nav class="navbar navbar-light bg-faded">
<div class="container-fluid">
<div class="navbar-header">
<img src="/assets/logo-de7018dbfd264fe7911d4f13f8ae89a4697a4624ae01a49de6e8df3f8e507041.png"" class="navbar-brand" id="logo" href="zigexn.vn">
<a href="http://zigexn.vn">
<img src="/assets/logo-de7018dbfd264fe7911d4f13f8ae89a4697a4624ae01a49de6e8df3f8e507041.png"" class="navbar-brand" id="logo">
</a>
</div>
<ul class="nav navbar-nav" id="slide">
<li><button type="button" class="btn btn-info" id="distance">Login</button></li>
......
<% @cities.each do |city| %>
<div class="col-md-4 column_set">
<%= render partial: "city",locals: {city: city} unless city.jobs.count.zero? %>
</div>
<% end %>
<div class="container">
<div class=" row align-items-start">
<%= render partial: "city",collection: @cities, as: :city %>
</div>
</div>
<div>
<%= link_to '<button type="button" class="btn btn-success" id="cities_button" >All Cities</button>'.html_safe, cities_path %>
</div>
\ No newline at end of file
<a href="#" class="titlejob">
<p>
<%= city.location %>
</p>
</a>
<li class="total_jobs">
<%= city.jobs.count %> Jobs
</li>
\ No newline at end of file
<div class="col-4">
<a href="#">
<p class="name_list_top">
<%= city.location %>
</p>
</a>
<li class="total_jobs">
<%= city.job_cities_count %> Jobs
</li>
</div>
......@@ -2,7 +2,7 @@
<ul>
<li>
<a href=""><%= city.location %></a>
(<%= city.jobs.count %>)
(<%= city.job_cities_count %>)
</li>
</ul>
</div>
\ No newline at end of file
<div class="jobs list-group-item">
<% @jobs.each do |job| %>
<%= render partial: "job",locals: {job: job} %>
<% end %>
<%= render partial: "job",collection: @jobs, as: :job %>
</div>
\ No newline at end of file
<% @industries.each do |industry| %>
<%= render partial: "industr",locals: {industr: industry} %>
<% end %>
<%= render partial: "industry",collection: @industries, as: :industry %>
<div>
<%= link_to'<button type="button" class="btn btn-success" id="cities_button">All Industry</button>'.html_safe, industries_path %>
<%= link_to'<button type="button" class="btn btn-success" id="industries_button">All Industry</button>'.html_safe, industries_path %>
</div>
\ No newline at end of file
<div class="col-md-4 column_set">
<a href="#" class="titlejob">
<p>
<%= industr.industry_name %>
<%= industry.industry_name %>
</a>
(<%= industr.jobs.count %>)
(<%= industry.jobs.count unless industry.jobs.count.zero? %>)
</p>
</div>
\ No newline at end of file
<% provide(:title, "Job List") %>
\ No newline at end of file
<p class="text-success line_job">Industry List</p>
<div class="row">
<% @industries_page.each do |industr| %>
<%= render partial: "industry_list", locals: {industry: industr} unless industr.jobs.count.zero?%>
<% @industries_page.each do |industry| %>
<%= render partial: "industry_list", locals: {industry: industry} unless industry.jobs.count.zero?%>
<% end %>
</div>
......@@ -16,7 +16,7 @@
</div>
<p class="text-success line_job">Top Cities</p>
<div class="row cities">
<div class="cities">
<%= render 'cities' %>
</div>
......
Rails.application.routes.draw do
get '/cities', to: 'top_pages#cities'
get '/industries', to: 'top_pages#industries'
# get '/job', to: '#'
get '/jobs', to: 'top_pages#jobs'
get 'top_pages/cities'
get 'top_pages/industries'
get 'top_pages/top_page'
get 'top_pages/job'
get 'top_pages/jobs'
root 'top_pages#top_page'
end
class AddBooleanToCities < ActiveRecord::Migration[5.1]
def change
add_column :cities, :is_vietnam, :boolean
end
end
class AddJobsCount < ActiveRecord::Migration[5.1]
def change
add_column :industries, :job_industries_count, :integer, default: 0
end
end
class AddJobsCountCity < ActiveRecord::Migration[5.1]
def change
add_column :cities, :job_cities_count, :integer, default: 0
end
end
......@@ -10,12 +10,14 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170913062114) do
ActiveRecord::Schema.define(version: 20170914072404) do
create_table "cities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "location"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "is_vietnam"
t.integer "job_cities_count", default: 0
end
create_table "companies", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
......@@ -30,6 +32,7 @@ ActiveRecord::Schema.define(version: 20170913062114) do
t.string "industry_name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "job_industries_count", default: 0
end
create_table "job_cities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
......
namespace :count do
task jobs_counter: :environment do
Industry.reset_column_information
Industry.find_each do |project|
Industry.reset_counters project.id, :jobs
end
end
end
\ No newline at end of file
namespace :count do
task jobs_counter_from_city: :environment do
City.reset_column_information
City.find_each do |project|
City.reset_counters project.id, :jobs
end
end
end
\ No newline at end of file
......@@ -12,9 +12,11 @@ namespace :crawl do
url_cities = "http://careerbuilder.vn/viec-lam/tat-ca-viec-lam-vi.html"
home_page = Nokogiri::HTML(open(url_cities))
cities = home_page.css('div.box_multiSelect_location select option')
is_vietnam = true
cities.each do |city|
next if city.text == 'Tất cả địa điểm'
City.find_or_create_by!(location: city.text)
is_vietnam = false if city.text == 'Angola'
City.find_or_create_by!(location: city.text, is_vietnam: is_vietnam)
end
#get industry and save database
......
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