Commit 36b7290d by Ngô Trung Hưng

fix bug

parent 92724316
......@@ -236,11 +236,11 @@ $main-color: #221f20;
}
.slogan_text {
text-align: center;
font-family: sans-serif;
font-family: 'Raleway', sans-serif;
font-size: 35px;
color: #eaeaea;
transform: scale(1.35);
font-weight: 600;
font-weight: 700;
margin: 0;
padding: 0;
}
......@@ -670,9 +670,11 @@ $main-color: #221f20;
-webkit-box-orient: vertical;
}
.box_info_location {
font-size: 13px;
font-size: 14px;
color: #666;
margin-top: 5px;
margin-top: -4px;
line-height: 24px;
}
.box_info_salary {
font-size: 13px;
......@@ -687,7 +689,17 @@ $main-color: #221f20;
// background-color: #d41323;
}
.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%;
overflow: hidden;
text-overflow: ellipsis;
......@@ -699,7 +711,7 @@ $main-color: #221f20;
.box_info_des {
width: 100%;
font-size: 12.5px;
line-height: 12.5px;
line-height: 13px;
color: #888;
margin: 0;
}
......@@ -817,6 +829,10 @@ $main-color: #221f20;
background-color: white;
}
.loc {
margin-top: 5px;
width: 90%;
}
.btn_search_submit {
height: 30px;
}
......
......@@ -3,9 +3,7 @@ class HomeController < ApplicationController
def index
@data_industries = Industry.sort_asc.all
@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
end
end
class Company < ApplicationRecord
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
......@@ -12,4 +12,5 @@ class Job < ApplicationRecord
has_many :histories
has_many :favorites
end
<% provide(:title ,'Trang chủ') %>
<%= render 'home/banner_and_search' %>
<div class="padding_index"></div>
<div class="box_text_five_jobs">
......
......@@ -2,6 +2,7 @@
<div class="container">
<div class="row">
<div class="col-sm-12">
<% i = 0%>
<% @data_five_jobs.each do |val| %>
<div class="box_jobs">
<div class="col-sm-12 d-block d-sm-none">
......@@ -15,13 +16,21 @@
<div class="col-sm-10 col-md-9 col-lg-10">
<div class="box_info">
<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" %>
</div>
<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>
<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>
<div class="coc" >
<h5 class="box_info_des"><%= strip_tags(val.description) %></h5>
......
......@@ -14,7 +14,7 @@ default: &default
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: '12345678'
password: '1'
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 @@
#
# 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|
t.bigint "user_id"
......@@ -88,6 +88,7 @@ ActiveRecord::Schema.define(version: 2020_07_15_090747) do
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "newdata"
end
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
......
......@@ -44,12 +44,15 @@ class Clawler
# FILL DATA COMPANIES
def self.make_companies
Company.create!(name: "Company name",
address: "Vui lòng trong mô tả công việc",
short_description: "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 xem trong mô tả công việc")
@data = Interface_web.craw_data_companies()
i = @data[:name].length
i.times do |n|
name = @data[:name][n]
if Company.find_by("name = ?", name)
next
else
address = @data[:address][n]
short_description = @data[:description][n]
Company.create!(name: name,
......@@ -57,9 +60,10 @@ class Clawler
short_description: short_description)
end
end
end
# FILL DATA JOBS
def self.make_jobs
Job.update_all(newdata: 0)
@data_jobs = Interface_web.make_data()
i = @data_jobs[:name].length
i.times do |n|
......@@ -85,7 +89,8 @@ class Clawler
salary: salary,
create_date: create_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_cities_table(@data_jobs[:city_name][n],id_job.id)
end
......
......@@ -21,9 +21,9 @@ class Interface_web
data << website_companies << website_jobs
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
@crawl_link_for_companies_jobs ||= crawl_link_for_companies_jobs(7)
@crawl_link_for_companies_jobs ||= crawl_link_for_companies_jobs(1)
end
def self.base_link(url)
......@@ -255,6 +255,7 @@ class Interface_web
end
def self.make_data
puts 'Please wait for crawl jobs data! . . .'
@data = {}
@name = []
@company_name = []
......@@ -268,6 +269,8 @@ class Interface_web
@city_name = []
link_crawl = get_link_job_and_companies
total_jobs = link_crawl[1].length
current_job = 1
link_crawl[1].each do |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
......@@ -275,6 +278,8 @@ class Interface_web
elsif page.search(".DetailJobNew ul li").size == 10
crawl_data_jobs_interface_5(path)
end
puts "Process: #{current_job}/#{total_jobs}"
current_job += 1
end
@data
end
......
......@@ -2,7 +2,7 @@ require 'src/crawler'
namespace :db do
task populate: :environment do
# Clawler.make_industries
Clawler.make_cities
# Clawler.make_cities
Clawler.make_companies
Clawler.make_jobs
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