Commit 36b7290d by Ngô Trung Hưng

fix bug

parent 92724316
...@@ -236,11 +236,11 @@ $main-color: #221f20; ...@@ -236,11 +236,11 @@ $main-color: #221f20;
} }
.slogan_text { .slogan_text {
text-align: center; text-align: center;
font-family: sans-serif; font-family: 'Raleway', sans-serif;
font-size: 35px; font-size: 35px;
color: #eaeaea; color: #eaeaea;
transform: scale(1.35); transform: scale(1.35);
font-weight: 600; font-weight: 700;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
...@@ -670,9 +670,11 @@ $main-color: #221f20; ...@@ -670,9 +670,11 @@ $main-color: #221f20;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
} }
.box_info_location { .box_info_location {
font-size: 13px; font-size: 14px;
color: #666; color: #666;
margin-top: 5px;
margin-top: -4px;
line-height: 24px;
} }
.box_info_salary { .box_info_salary {
font-size: 13px; font-size: 13px;
...@@ -687,7 +689,17 @@ $main-color: #221f20; ...@@ -687,7 +689,17 @@ $main-color: #221f20;
// background-color: #d41323; // background-color: #d41323;
} }
.coc { .coc {
height: 12.5px; height: 13px;
width:100%;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
margin-top: -3px;
}
.loc {
height: 24px;
width:100%; width:100%;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
...@@ -699,7 +711,7 @@ $main-color: #221f20; ...@@ -699,7 +711,7 @@ $main-color: #221f20;
.box_info_des { .box_info_des {
width: 100%; width: 100%;
font-size: 12.5px; font-size: 12.5px;
line-height: 12.5px; line-height: 13px;
color: #888; color: #888;
margin: 0; margin: 0;
} }
...@@ -817,6 +829,10 @@ $main-color: #221f20; ...@@ -817,6 +829,10 @@ $main-color: #221f20;
background-color: white; background-color: white;
} }
.loc {
margin-top: 5px;
width: 90%;
}
.btn_search_submit { .btn_search_submit {
height: 30px; height: 30px;
} }
......
...@@ -3,9 +3,7 @@ class HomeController < ApplicationController ...@@ -3,9 +3,7 @@ class HomeController < ApplicationController
def index def index
@data_industries = Industry.sort_asc.all @data_industries = Industry.sort_asc.all
@data_total_job = Job.all.count @data_total_job = Job.all.count
@data_five_jobs = Company.get_5_last_jobs() @data_five_jobs = Job.order(created_at: :asc).where(newdata: 1).limit(5)
@data_cities = City.all @data_cities = City.all
end end
end end
class Company < ApplicationRecord class Company < ApplicationRecord
has_many :jobs has_many :jobs
def self.get_5_last_jobs
data = Company.joins(:jobs).select('companies.*, jobs.name as job_title,
jobs.created_at as job_created,
jobs.salary,
jobs.description').where('companies.id = jobs.company_id')
@data_five_jobs = data.order(job_created: :asc).limit(5)
end
end end
...@@ -12,4 +12,5 @@ class Job < ApplicationRecord ...@@ -12,4 +12,5 @@ class Job < ApplicationRecord
has_many :histories has_many :histories
has_many :favorites has_many :favorites
end end
<% provide(:title ,'Trang chủ') %>
<%= render 'home/banner_and_search' %> <%= render 'home/banner_and_search' %>
<div class="padding_index"></div> <div class="padding_index"></div>
<div class="box_text_five_jobs"> <div class="box_text_five_jobs">
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<% i = 0%>
<% @data_five_jobs.each do |val| %> <% @data_five_jobs.each do |val| %>
<div class="box_jobs"> <div class="box_jobs">
<div class="col-sm-12 d-block d-sm-none"> <div class="col-sm-12 d-block d-sm-none">
...@@ -15,13 +16,21 @@ ...@@ -15,13 +16,21 @@
<div class="col-sm-10 col-md-9 col-lg-10"> <div class="col-sm-10 col-md-9 col-lg-10">
<div class="box_info"> <div class="box_info">
<div class="lol"> <div class="lol">
<%= link_to "#{val.job_title}", "#", class: "job_name" %> <%= link_to "#{val.name}", "#", class: "job_name" %>
<%= image_tag 'trophy',class: "img_job_name" %> <%= image_tag 'trophy',class: "img_job_name" %>
</div> </div>
<div class = "cop"> <div class = "cop">
<h5 class="box_info_copany_name"><i class="far fa-building"></i> <%= val.name %></h5> <h5 class="box_info_copany_name"><i class="far fa-building"></i> <%= val.company.name %></h5>
</div>
<div class="loc">
<h5 class="box_info_location"><i class="fas fa-map-marker-alt"></i>
<% @dt = [] %>
<% val.cities.each do |x| %>
<% @dt << (x.name << ' | ') %>
<% end %>
<%= @dt.join('').chomp('| ')%>
</h5>
</div> </div>
<h5 class="box_info_location"><i class="fas fa-map-marker-alt"></i> <%= val.address %></h5>
<h5 class="box_info_salary"><i class="fas fa-dollar-sign"></i> Lương: <%= val.salary %></h5> <h5 class="box_info_salary"><i class="fas fa-dollar-sign"></i> Lương: <%= val.salary %></h5>
<div class="coc" > <div class="coc" >
<h5 class="box_info_des"><%= strip_tags(val.description) %></h5> <h5 class="box_info_des"><%= strip_tags(val.description) %></h5>
......
...@@ -14,7 +14,7 @@ default: &default ...@@ -14,7 +14,7 @@ default: &default
encoding: utf8 encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root username: root
password: '12345678' password: '1'
socket: /var/run/mysqld/mysqld.sock socket: /var/run/mysqld/mysqld.sock
......
class AddColumnNewdataToTableJobs < ActiveRecord::Migration[5.2]
def change
add_column :jobs, :newdata, :boolean
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_07_15_090747) do ActiveRecord::Schema.define(version: 2020_07_20_035021) do
create_table "applied_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "applied_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.bigint "user_id" t.bigint "user_id"
...@@ -88,6 +88,7 @@ ActiveRecord::Schema.define(version: 2020_07_15_090747) do ...@@ -88,6 +88,7 @@ ActiveRecord::Schema.define(version: 2020_07_15_090747) do
t.text "description" t.text "description"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.boolean "newdata"
end end
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
......
...@@ -44,12 +44,15 @@ class Clawler ...@@ -44,12 +44,15 @@ class Clawler
# FILL DATA COMPANIES # FILL DATA COMPANIES
def self.make_companies def self.make_companies
Company.create!(name: "Company name", Company.create!(name: "Company name",
address: "Vui lòng trong mô tả công việc", address: "Vui lòng xem trong mô tả công việc",
short_description: "Vui lòng trong mô tả công việc") short_description: "Vui lòng xem trong mô tả công việc")
@data = Interface_web.craw_data_companies() @data = Interface_web.craw_data_companies()
i = @data[:name].length i = @data[:name].length
i.times do |n| i.times do |n|
name = @data[:name][n] name = @data[:name][n]
if Company.find_by("name = ?", name)
next
else
address = @data[:address][n] address = @data[:address][n]
short_description = @data[:description][n] short_description = @data[:description][n]
Company.create!(name: name, Company.create!(name: name,
...@@ -57,9 +60,10 @@ class Clawler ...@@ -57,9 +60,10 @@ class Clawler
short_description: short_description) short_description: short_description)
end end
end end
end
# FILL DATA JOBS # FILL DATA JOBS
def self.make_jobs def self.make_jobs
Job.update_all(newdata: 0)
@data_jobs = Interface_web.make_data() @data_jobs = Interface_web.make_data()
i = @data_jobs[:name].length i = @data_jobs[:name].length
i.times do |n| i.times do |n|
...@@ -85,7 +89,8 @@ class Clawler ...@@ -85,7 +89,8 @@ class Clawler
salary: salary, salary: salary,
create_date: create_date, create_date: create_date,
expiration_date: expiration_date, expiration_date: expiration_date,
description: description) description: description,
newdata: 1)
self.make_foreign_industries_table(@data_jobs[:industry_name][n],id_job.id) self.make_foreign_industries_table(@data_jobs[:industry_name][n],id_job.id)
self.make_foreign_cities_table(@data_jobs[:city_name][n],id_job.id) self.make_foreign_cities_table(@data_jobs[:city_name][n],id_job.id)
end end
......
...@@ -21,9 +21,9 @@ class Interface_web ...@@ -21,9 +21,9 @@ class Interface_web
data << website_companies << website_jobs data << website_companies << website_jobs
end end
@crawl_link_for_companies_jobs = crawl_link_for_companies_jobs(7) @crawl_link_for_companies_jobs = crawl_link_for_companies_jobs(1)
def self.get_link_job_and_companies def self.get_link_job_and_companies
@crawl_link_for_companies_jobs ||= crawl_link_for_companies_jobs(7) @crawl_link_for_companies_jobs ||= crawl_link_for_companies_jobs(1)
end end
def self.base_link(url) def self.base_link(url)
...@@ -255,6 +255,7 @@ class Interface_web ...@@ -255,6 +255,7 @@ class Interface_web
end end
def self.make_data def self.make_data
puts 'Please wait for crawl jobs data! . . .'
@data = {} @data = {}
@name = [] @name = []
@company_name = [] @company_name = []
...@@ -268,6 +269,8 @@ class Interface_web ...@@ -268,6 +269,8 @@ class Interface_web
@city_name = [] @city_name = []
link_crawl = get_link_job_and_companies link_crawl = get_link_job_and_companies
total_jobs = link_crawl[1].length
current_job = 1
link_crawl[1].each do |path| link_crawl[1].each do |path|
page = Nokogiri::HTML(URI.open(URI.parse(URI.escape("https://careerbuilder.vn/#{path}")))) page = Nokogiri::HTML(URI.open(URI.parse(URI.escape("https://careerbuilder.vn/#{path}"))))
if page.search(".item-blue .detail-box:nth-child(1) ul li:nth-child(1) p")[0] != nil if page.search(".item-blue .detail-box:nth-child(1) ul li:nth-child(1) p")[0] != nil
...@@ -275,6 +278,8 @@ class Interface_web ...@@ -275,6 +278,8 @@ class Interface_web
elsif page.search(".DetailJobNew ul li").size == 10 elsif page.search(".DetailJobNew ul li").size == 10
crawl_data_jobs_interface_5(path) crawl_data_jobs_interface_5(path)
end end
puts "Process: #{current_job}/#{total_jobs}"
current_job += 1
end end
@data @data
end end
......
...@@ -2,7 +2,7 @@ require 'src/crawler' ...@@ -2,7 +2,7 @@ require 'src/crawler'
namespace :db do namespace :db do
task populate: :environment do task populate: :environment do
# Clawler.make_industries # Clawler.make_industries
Clawler.make_cities # Clawler.make_cities
Clawler.make_companies Clawler.make_companies
Clawler.make_jobs Clawler.make_jobs
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