Commit f59a5899 by Xuan Trung Le

update rspec

parent 15f96a1e
...@@ -23,3 +23,14 @@ ...@@ -23,3 +23,14 @@
# Ignore public # Ignore public
/public /public
# vendor/bundle
/vendor
# spec
.vscode
.rspec
# Guardfile
Guardfile
jobs.zip
spec/*
Subproject commit 1c8c516526ca783c5c4903d35d325f624234a74b
...@@ -6,29 +6,34 @@ git_source(:github) do |repo_name| ...@@ -6,29 +6,34 @@ git_source(:github) do |repo_name|
end end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'carrierwave'
gem 'rails', '~> 5.1.4' gem 'devise'
# Use mysql as the database for Active Record gem 'faker'
gem 'figaro'
gem 'kaminari'
gem 'mysql2', '>= 0.3.18', '< 0.5' gem 'mysql2', '>= 0.3.18', '< 0.5'
# Use Puma as the app server
gem 'puma', '~> 3.7' gem 'puma', '~> 3.7'
# Use SCSS for stylesheets gem 'rails', '~> 5.1.4'
gem 'rsolr-ext'
gem 'rsolr'
gem 'rubyzip'
gem 'sass-rails', '~> 5.0' gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets gem 'sidekiq'
gem 'uglifier', '>= 1.3.0' gem 'uglifier', '>= 1.3.0'
gem 'figaro'
gem 'devise'
gem 'carrierwave'
gem 'kaminari'
gem "settingslogic" gem "settingslogic"
gem 'sidekiq' gem "redis-rails"
gem 'rsolr'
gem 'rubyzip'
gem 'rsolr-ext'
group :development, :test do group :development, :test do
gem 'rack-mini-profiler', require: false
# Call 'byebug' anywhere in the code to stop execution and get a debugger console # Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] # gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'pry-byebug'
gem 'pry-rails'
gem 'byebug'
gem 'rspec-rails', '~> 3.4'
gem 'capybara'
gem 'factory_girl_rails'
gem 'guard-rspec', require: false
end end
group :development do group :development do
...@@ -38,5 +43,11 @@ group :development do ...@@ -38,5 +43,11 @@ group :development do
gem 'spring' gem 'spring'
end end
group :test do
gem 'shoulda-matchers', '~> 3.0', require: false
gem 'database_cleaner', '~> 1.5'
gem 'faker'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
...@@ -38,34 +38,68 @@ GEM ...@@ -38,34 +38,68 @@ GEM
i18n (~> 0.7) i18n (~> 0.7)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
arel (8.0.0) arel (8.0.0)
bcrypt (3.1.11) bcrypt (3.1.11)
bindex (0.5.0) bindex (0.5.0)
builder (3.2.3) builder (3.2.3)
byebug (9.1.0) byebug (9.1.0)
capybara (2.16.1)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
carrierwave (1.2.1) carrierwave (1.2.1)
activemodel (>= 4.0.0) activemodel (>= 4.0.0)
activesupport (>= 4.0.0) activesupport (>= 4.0.0)
mime-types (>= 1.16) mime-types (>= 1.16)
coderay (1.1.2)
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
connection_pool (2.2.1) connection_pool (2.2.1)
crass (1.0.2) crass (1.0.3)
database_cleaner (1.6.2)
devise (4.3.0) devise (4.3.0)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2) railties (>= 4.1.0, < 5.2)
responders responders
warden (~> 1.2.3) warden (~> 1.2.3)
diff-lcs (1.3)
erubi (1.7.0) erubi (1.7.0)
execjs (2.7.0) execjs (2.7.0)
factory_girl (4.9.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.9.0)
factory_girl (~> 4.9.0)
railties (>= 3.0.0)
faker (1.8.4)
i18n (~> 0.5)
faraday (0.13.1) faraday (0.13.1)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
ffi (1.9.18) ffi (1.9.18)
figaro (1.1.1) figaro (1.1.1)
thor (~> 0.14) thor (~> 0.14)
formatador (0.2.5)
globalid (0.4.1) globalid (0.4.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
i18n (0.9.0) guard (2.14.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
i18n (0.9.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
kaminari (1.1.1) kaminari (1.1.1)
activesupport (>= 4.1.0) activesupport (>= 4.1.0)
...@@ -79,29 +113,49 @@ GEM ...@@ -79,29 +113,49 @@ GEM
activerecord activerecord
kaminari-core (= 1.1.1) kaminari-core (= 1.1.1)
kaminari-core (1.1.1) kaminari-core (1.1.1)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.1.1) loofah (2.1.1)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
lumberjack (1.0.12)
mail (2.7.0) mail (2.7.0)
mini_mime (>= 0.1.1) mini_mime (>= 0.1.1)
method_source (0.9.0) method_source (0.9.0)
mime-types (3.1) mime-types (3.1)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521) mime-types-data (3.2016.0521)
mini_mime (0.1.4) mini_mime (1.0.0)
mini_portile2 (2.3.0) mini_portile2 (2.3.0)
minitest (5.10.3) minitest (5.10.3)
multipart-post (2.0.0) multipart-post (2.0.0)
mysql2 (0.4.9) mysql2 (0.4.10)
nenv (0.3.0)
nio4r (2.1.0) nio4r (2.1.0)
nokogiri (1.8.1) nokogiri (1.8.1)
mini_portile2 (~> 2.3.0) mini_portile2 (~> 2.3.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
orm_adapter (0.5.0) orm_adapter (0.5.0)
puma (3.10.0) pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-byebug (3.5.1)
byebug (~> 9.1)
pry (~> 0.10)
pry-rails (0.3.6)
pry (>= 0.10.4)
public_suffix (3.0.1)
puma (3.11.0)
rack (2.0.3) rack (2.0.3)
rack-mini-profiler (0.10.7)
rack (>= 1.2.0)
rack-protection (2.0.0) rack-protection (2.0.0)
rack rack
rack-test (0.7.0) rack-test (0.8.2)
rack (>= 1.0, < 3) rack (>= 1.0, < 3)
rails (5.1.4) rails (5.1.4)
actioncable (= 5.1.4) actioncable (= 5.1.4)
...@@ -126,32 +180,73 @@ GEM ...@@ -126,32 +180,73 @@ GEM
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rake (12.2.1) rake (12.3.0)
rb-fsevent (0.10.2) rb-fsevent (0.10.2)
rb-inotify (0.9.10) rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2) ffi (>= 0.5.0, < 2)
redis (4.0.1) redis (4.0.1)
redis-actionpack (5.0.2)
actionpack (>= 4.0, < 6)
redis-rack (>= 1, < 3)
redis-store (>= 1.1.0, < 2)
redis-activesupport (5.0.4)
activesupport (>= 3, < 6)
redis-store (>= 1.3, < 2)
redis-rack (2.0.3)
rack (>= 1.5, < 3)
redis-store (>= 1.2, < 2)
redis-rails (5.0.2)
redis-actionpack (>= 5.0, < 6)
redis-activesupport (>= 5.0, < 6)
redis-store (>= 1.2, < 2)
redis-store (1.4.1)
redis (>= 2.2, < 5)
responders (2.4.0) responders (2.4.0)
actionpack (>= 4.2.0, < 5.3) actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3)
rsolr (2.0.2) rsolr (2.1.0)
builder (>= 2.1.2) builder (>= 2.1.2)
faraday faraday (>= 0.9.0)
rsolr-ext (1.0.3) rsolr-ext (1.0.3)
rsolr (>= 1.0.2) rsolr (>= 1.0.2)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.0)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-rails (3.7.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
ruby_dep (1.5.0)
rubyzip (1.2.1) rubyzip (1.2.1)
sass (3.5.3) sass (3.5.3)
sass-listen (~> 4.0.0) sass-listen (~> 4.0.0)
sass-listen (4.0.0) sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.6) sass-rails (5.0.7)
railties (>= 4.0.0, < 6) railties (>= 4.0.0, < 6)
sass (~> 3.1) sass (~> 3.1)
sprockets (>= 2.8, < 4.0) sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0) sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3) tilt (>= 1.1, < 3)
settingslogic (2.0.9) settingslogic (2.0.9)
shellany (0.0.1)
shoulda-matchers (3.1.2)
activesupport (>= 4.0.0)
sidekiq (5.0.5) sidekiq (5.0.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0) connection_pool (~> 2.2, >= 2.2.0)
...@@ -171,7 +266,7 @@ GEM ...@@ -171,7 +266,7 @@ GEM
tilt (2.0.8) tilt (2.0.8)
tzinfo (1.2.4) tzinfo (1.2.4)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (3.2.0) uglifier (4.0.1)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
warden (1.2.7) warden (1.2.7)
rack (>= 1.0) rack (>= 1.0)
...@@ -182,25 +277,38 @@ GEM ...@@ -182,25 +277,38 @@ GEM
railties (>= 5.0) railties (>= 5.0)
websocket-driver (0.6.5) websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2) websocket-extensions (0.1.3)
xpath (2.1.0)
nokogiri (~> 1.3)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
byebug byebug
capybara
carrierwave carrierwave
database_cleaner (~> 1.5)
devise devise
factory_girl_rails
faker
figaro figaro
guard-rspec
kaminari kaminari
mysql2 (>= 0.3.18, < 0.5) mysql2 (>= 0.3.18, < 0.5)
pry-byebug
pry-rails
puma (~> 3.7) puma (~> 3.7)
rack-mini-profiler
rails (~> 5.1.4) rails (~> 5.1.4)
redis-rails
rsolr rsolr
rsolr-ext rsolr-ext
rspec-rails (~> 3.4)
rubyzip rubyzip
sass-rails (~> 5.0) sass-rails (~> 5.0)
settingslogic settingslogic
shoulda-matchers (~> 3.0)
sidekiq sidekiq
spring spring
tzinfo-data tzinfo-data
...@@ -208,4 +316,4 @@ DEPENDENCIES ...@@ -208,4 +316,4 @@ DEPENDENCIES
web-console (>= 3.3.0) web-console (>= 3.3.0)
BUNDLED WITH BUNDLED WITH
1.15.4 1.16.0
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
// Place all the styles related to the candidate controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class CandidateController < ApplicationController
end
require './app/models/settings.rb'
class JobsController < ApplicationController class JobsController < ApplicationController
before_action :set_job, only: [:show] before_action :set_job, only: [:show]
def index def index
...@@ -52,6 +50,16 @@ class JobsController < ApplicationController ...@@ -52,6 +50,16 @@ class JobsController < ApplicationController
render template: "jobs/job_lists" render template: "jobs/job_lists"
end end
def get_all
@jobs = Job.limit(50000)
puts @jobs.count
respond_to do |format|
# format.json { render json: @jobs, status: :ok }
format.json { render json: @jobs}
format.html {render 'get_all'}
end
end
private private
def set_job def set_job
......
...@@ -34,8 +34,8 @@ class Crawler ...@@ -34,8 +34,8 @@ class Crawler
params_company = {} params_company = {}
description = [] description = []
# get job's name # get job's name
params[:name] = doc.css('.top-job .top-job-info h1').text.strip params[:name] = doc.css('.top-job .top-job-info h1').text.try(:strip)
params[:updated_date] = doc.css('.datepost').text.split(':')[1].strip params[:updated_date] = doc.css('.datepost').text.split(':')[1].try(:strip)
# get company infoimation # get company infoimation
params_company = crawl_company_infomation(doc) params_company = crawl_company_infomation(doc)
...@@ -47,9 +47,9 @@ class Crawler ...@@ -47,9 +47,9 @@ class Crawler
doc.css('.MyJobLeft .box2Detail .DetailJobNew li').children.each do |child| doc.css('.MyJobLeft .box2Detail .DetailJobNew li').children.each do |child|
info = child.text.gsub(/\t|\n/, '').split(':') info = child.text.gsub(/\t|\n/, '').split(':')
next if info.blank? next if info.blank?
case info[0].strip.upcase case info[0].try(:strip).upcase
when 'NƠI LÀM VIỆC' when 'NƠI LÀM VIỆC'
params[:city] = info[1].strip params[:city] = info[1].try(:strip)
when 'CẤP BẬC' when 'CẤP BẬC'
params[:level] = info[1] params[:level] = info[1]
when 'KINH NGHIỆM' when 'KINH NGHIỆM'
...@@ -89,8 +89,14 @@ class Crawler ...@@ -89,8 +89,14 @@ class Crawler
end end
def self.get_job_links def self.get_job_links
url = "#{LIST_URL}/tat-ca-viec-lam-trang-#{1}-vi.html" i = 2
doc = Nokogiri::HTML(open(url)) links = []
doc.css('.gird_standard .brief .jobtitle .job a').map { |a| a['href'] }.compact.uniq while i < 30
url = "#{LIST_URL}/tat-ca-viec-lam-trang-#{i}-vi.html"
doc = Nokogiri::HTML(open(url))
links << doc.css('.gird_standard .brief .jobtitle .job a').map { |a| a['href'] }.compact.uniq
i += 1
end
links.flatten
end end
end end
class Candidate < ApplicationRecord
validates_presence_of :firstname, :lastname, :email
validates_length_of :firstname, maximum: 100
validates_length_of :lastname, maximum: 100
def active
true
end
end
<h1>Get all jobs in DB</h1>
...@@ -47,6 +47,11 @@ ...@@ -47,6 +47,11 @@
<i class="fa fa-history" aria-hidden="true"></i> History <i class="fa fa-history" aria-hidden="true"></i> History
<% end %> <% end %>
</li> </li>
<li>
<%= link_to all_jobs_path do %>
<i class="fa fa-globe" aria-hidden="true"></i> All Job
<% end %>
</li>
</ul> </ul>
</div> </div>
</nav> </nav>
...@@ -16,7 +16,8 @@ Rails.application.configure do ...@@ -16,7 +16,8 @@ Rails.application.configure do
if Rails.root.join('tmp/caching-dev.txt').exist? if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
config.cache_store = :memory_store # config.cache_store = :memory_store
config.cache_store = :redis_store, "redis://locahost:6379/1/ns"
config.public_file_server.headers = { config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
} }
......
if Rails.env.development?
require "rack-mini-profiler"
# initialization is skipped so trigger it
Rack::MiniProfilerRails.initialize!(Rails.application)
end
# $redis = Redis::Namespace.new("site_point", :redis => Redis.new)
...@@ -28,6 +28,7 @@ Rails.application.routes.draw do ...@@ -28,6 +28,7 @@ Rails.application.routes.draw do
get 'industry/:industry_id' => "jobs#industry", as: :industry get 'industry/:industry_id' => "jobs#industry", as: :industry
get 'company/:company_id' => "jobs#company", as: :company get 'company/:company_id' => "jobs#company", as: :company
get 'search' => "jobs#search" get 'search' => "jobs#search"
get 'all' => "jobs#get_all"
end end
end end
resources :my_pages, path: '', only: [:index] do resources :my_pages, path: '', only: [:index] do
......
class CreateCandidates < ActiveRecord::Migration[5.1]
def change
create_table :candidates do |t|
t.string :firstname
t.string :lastname
t.string :email
t.datetime :applied_at
t.timestamps
end
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: 20171101064311) do ActiveRecord::Schema.define(version: 20171204063833) do
create_table "admins", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "admins", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "email", default: "", null: false t.string "email", default: "", null: false
...@@ -41,6 +41,15 @@ ActiveRecord::Schema.define(version: 20171101064311) do ...@@ -41,6 +41,15 @@ ActiveRecord::Schema.define(version: 20171101064311) do
t.index ["user_id"], name: "index_apply_jobs_on_user_id" t.index ["user_id"], name: "index_apply_jobs_on_user_id"
end end
create_table "candidates", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "firstname"
t.string "lastname"
t.string "email"
t.datetime "applied_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "cities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "cities", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "name" t.string "name"
t.bigint "country_id" t.bigint "country_id"
......
viet_nam = Country.create(name: 'Viet Nam') # viet_nam = Country.create(name: 'Viet Nam')
another = Country.create(name: 'another') # another = Country.create(name: 'another')
#
cities_of_vn = ["Hà Nội", "Hồ Chí Minh", "An Giang", "Bà Rịa - Vũng Tàu", "Bạc Liêu", "Bắc Giang", # cities_of_vn = ["Hà Nội", "Hồ Chí Minh", "An Giang", "Bà Rịa - Vũng Tàu", "Bạc Liêu", "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", # "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", # "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", # "Đồ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", # "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ộ", # "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", "Long An", # "KV Nam Trung Bộ", "KV Tây Nguyên", "Lai Châu", "Lạng Sơn", "Lào Cai", "Long An",
"Nam Định", "Nghệ An", "Ninh Thuận", "Phú Thọ", "Phú Yên", "Quảng Bình", "Quảng Nam", # "Nam Định", "Nghệ An", "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", # "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", # "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"] # "Tuyên Quang", "Vĩnh Long", "Vĩnh Phúc", "Yên Bái"]
cities_of_another_country = [ # cities_of_another_country = [
"Banteay Meanchey", "Battambang", # "Banteay Meanchey", "Battambang",
"Kampong Chhnang", "Kampong Speu", "Kampot", "Kandal", "Kâmpóng Thum, Cambodia", # "Kampong Chhnang", "Kampong Speu", "Kampot", "Kandal", "Kâmpóng Thum, Cambodia",
"Kep", "Koh Kong", "Kratie", "Mondulkiri", "Otdar Meanchey", "Pailin", "Phnompenh", # "Kep", "Koh Kong", "Kratie", "Mondulkiri", "Otdar Meanchey", "Pailin", "Phnompenh",
"Preah Sihanouk", "Preah Vihear", "Prey Veng", "Pursat", "Rotanak Kiri", "Siem Reap", # "Preah Sihanouk", "Preah Vihear", "Prey Veng", "Pursat", "Rotanak Kiri", "Siem Reap",
"Sihanoukville", "Stung Treng", "Svay Rieng", "Tbong Khmum", "Kinshasa", "Hồng Kông", # "Sihanoukville", "Stung Treng", "Svay Rieng", "Tbong Khmum", "Kinshasa", "Hồng Kông",
"Attapeu", "Bokeo", "Bolikhamsai", "Champasak", "Houaphanh", "Khammouane", # "Attapeu", "Bokeo", "Bolikhamsai", "Champasak", "Houaphanh", "Khammouane",
"Louang Namtha", "Luang Prabang", "Oudomxay", "Phongsaly", "Sainyabuli", "Salavan", # "Louang Namtha", "Luang Prabang", "Oudomxay", "Phongsaly", "Sainyabuli", "Salavan",
"Savannakhet", "Sekong", "Vientiane", "Xaisomboun", "Xiangkhouang", "Qatar"] # "Savannakhet", "Sekong", "Vientiane", "Xaisomboun", "Xiangkhouang", "Qatar"]
#
cities_of_vn.each do |city_name| # cities_of_vn.each do |city_name|
City.create(name: city_name, country: viet_nam) # City.create(name: city_name, country: viet_nam)
end # end
#
cities_of_another_country.each do |city_name| # cities_of_another_country.each do |city_name|
City.create(name: city_name, country: another) # City.create(name: city_name, country: another)
# end
# ["id", "name", "salary", "description", "level", "experience", "company_id", "expiry_date", "updated_date", "updated_at", "created_at", "original_link"]
Company.all.limit(10).each do |company|
10000.times{
Job.create(name: Faker::Job.title,
salary: Faker::Number.number(10),
description: Faker::Lorem.paragraph(2),
level: Faker::LeagueOfLegends.rank,
experience: 'No require',
company_id: company.id,
expiry_date: 1.years.since)
puts "Creating #{Faker::Job.title}"
}
end end
...@@ -2,6 +2,7 @@ require "./app/data/crawler.rb" ...@@ -2,6 +2,7 @@ require "./app/data/crawler.rb"
# require './app/data/import.rb' # require './app/data/import.rb'
namespace :data do namespace :data do
desc 'insert job from careerbuilder'
task insert_job: :environment do |t| task insert_job: :environment do |t|
links = Crawler.get_job_links links = Crawler.get_job_links
links = Job.filter_link_exist(links) links = Job.filter_link_exist(links)
......
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