Commit 4432b5e6 by thanhnd

fix review phase 1 20200219 11:27

parent d4068924
Pipeline #469 failed with stages
in 0 seconds
class CreateCities < ActiveRecord::Migration[6.0] class CreateCities < ActiveRecord::Migration[6.0]
def change def change
create_table :cities do |t| create_table :cities do |t|
t.int :area_id t.integer :area_id
t.string :city_name t.string :city_name
t.string :city_description t.string :city_description
t.timestamps t.timestamps
end end
add_index :city_name
end end
end end
...@@ -10,7 +10,5 @@ class CreateCompanies < ActiveRecord::Migration[6.0] ...@@ -10,7 +10,5 @@ class CreateCompanies < ActiveRecord::Migration[6.0]
t.string :size t.string :size
t.timestamps t.timestamps
end end
add_index :companies_name
add_index :email
end end
end end
class CreateIndustryJobs < ActiveRecord::Migration[6.0] class CreateIndustryJobs < ActiveRecord::Migration[6.0]
def change def change
create_table :industry_jobs do |t| create_table :industry_jobs do |t|
t.int :industry_id t.integer :industry_id
t.int :job_id t.integer :job_id
t.timestamps t.timestamps
end end
end end
......
class CreateJobs < ActiveRecord::Migration[6.0] class CreateJobs < ActiveRecord::Migration[6.0]
def change def change
create_table :jobs do |t| create_table :jobs do |t|
t.int :area_id t.integer :area_id
t.int :city_id t.integer :city_id
t.int :industry_id t.integer :industry_id
t.int :company_id t.integer :company_id
t.text :job_name t.text :job_name
t.string :salary t.string :salary
t.datetime :deadline t.datetime :deadline
......
...@@ -4,7 +4,7 @@ class CreateUsers < ActiveRecord::Migration[6.0] ...@@ -4,7 +4,7 @@ class CreateUsers < ActiveRecord::Migration[6.0]
t.string :email t.string :email
t.string :fname t.string :fname
t.string :lname t.string :lname
t.int :role t.integer :role
t.string :remember_digest t.string :remember_digest
t.string :activation_digest t.string :activation_digest
t.boolean :activated t.boolean :activated
......
class CreateSavedJobs < ActiveRecord::Migration[6.0] class CreateSavedJobs < ActiveRecord::Migration[6.0]
def change def change
create_table :saved_jobs do |t| create_table :saved_jobs do |t|
t.int :user_id t.integer :user_id
t.int :job_id t.integer :job_id
t.timestamps t.timestamps
end end
end end
......
class CreateAppliedJobs < ActiveRecord::Migration[6.0] class CreateAppliedJobs < ActiveRecord::Migration[6.0]
def change def change
create_table :applied_jobs do |t| create_table :applied_jobs do |t|
t.int :user_id t.integer :user_id
t.int :job_id t.integer :job_id
t.timestamps t.timestamps
end end
end end
......
class RemoveColumnCodeJobtable < ActiveRecord::Migration[6.0]
def change
remove_column :jobs, :code
end
end
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
# #
# 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_02_11_083438) do ActiveRecord::Schema.define(version: 2020_02_04_084755) 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.integer "user_id", null: false t.integer "user_id"
t.integer "job_id", null: false t.integer "job_id"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
end end
...@@ -32,7 +32,6 @@ ActiveRecord::Schema.define(version: 2020_02_11_083438) do ...@@ -32,7 +32,6 @@ ActiveRecord::Schema.define(version: 2020_02_11_083438) do
t.string "city_description" t.string "city_description"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.index ["area_id"], name: "index_cities_on_area_id"
end end
create_table "companies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "companies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
...@@ -42,60 +41,59 @@ ActiveRecord::Schema.define(version: 2020_02_11_083438) do ...@@ -42,60 +41,59 @@ ActiveRecord::Schema.define(version: 2020_02_11_083438) do
t.string "phone_number" t.string "phone_number"
t.string "website" t.string "website"
t.string "email" t.string "email"
t.integer "size" t.string "size"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
t.index ["email"], name: "index_companies_on_email"
end end
create_table "industries", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "industries", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.text "industry_name", null: false t.text "industry_name"
t.string "industry_description" t.string "industry_description"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
end end
create_table "industry_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "industry_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.integer "industry_id", null: false t.integer "industry_id"
t.integer "job_id", null: false t.integer "job_id"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
end end
create_table "jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.integer "area_id", null: false t.integer "area_id"
t.integer "city_id", null: false t.integer "city_id"
t.integer "industry_id", null: false t.integer "industry_id"
t.integer "company_id", null: false t.integer "company_id"
t.text "job_name", null: false t.text "job_name"
t.string "salary" t.string "salary"
t.date "deadline" t.datetime "deadline"
t.string "level" t.string "level"
t.string "experience" t.string "experience"
t.date "last_updated" t.datetime "last_updated"
t.text "description" t.text "description"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
end end
create_table "saved_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "saved_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.integer "user_id", null: false t.integer "user_id"
t.integer "job_id", null: false t.integer "job_id"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
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|
t.string "email", null: false t.string "email"
t.string "fname", null: false t.string "fname"
t.string "lname", null: false t.string "lname"
t.integer "role", null: false t.integer "role"
t.string "remember_digest" t.string "remember_digest"
t.string "activation_digest" t.string "activation_digest"
t.boolean "activated" t.boolean "activated"
t.timestamp "activated_at" t.datetime "activated_at"
t.string "reset_digest" t.string "reset_digest"
t.timestamp "reset_sent_at" t.datetime "reset_sent_at"
t.string "password_digest" t.string "password_digest"
t.datetime "created_at", precision: 6, null: false t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false
......
...@@ -50,20 +50,16 @@ namespace :crawler do ...@@ -50,20 +50,16 @@ namespace :crawler do
#insert data to City table: #insert data to City table:
city_name = location.text.gsub(",", "") city_name = location.text.gsub(",", "")
City.find_or_create_by(area_id: area.id, city_name: city_name, city_description: "") city = City.find_or_create_by(area_id: area.id, city_name: city_name, city_description: "")
#insert data to Industry table #insert data to Industry table
Industry.find_or_create_by(industry_name: industry.text, industry_description: "") industry = Industry.find_or_create_by(industry_name: industry.text, industry_description: "")
#insert data to Companies table #insert data to Companies table
Company.find_or_create_by(company_name: company_name.text, company_description: company_intro.text, address: address.text) company = Company.find_or_create_by(company_name: company_name.text, company_description: company_intro.text, address: address.text)
#insert data to Jobs table #insert data to Jobs table
city = City.find_by(area_id: area.id, city_name: city_name) Job.find_or_create_by(area_id: area.id, city_id: city.id , industry_id: industry.id, company_id: company.id, job_name: title.text, salary: salary.text, deadline: deadline.text, level: level.text, experience: experience.text.strip, last_updated: updated_date.text.strip, description: description.text)
industryid = Industry.find_by(industry_name: industry.text)
companyid = Company.find_by(company_name: company_name.text)
Job.find_or_create_by(area_id: area.id, city_id: city.id , industry_id: industryid.id, company_id: companyid.id, job_name: title.text, salary: salary.text, deadline: deadline.text, level: level.text, experience: experience.text.strip, last_updated: updated_date.text.strip, description: description.text)
end end
list_url = nextpage[0]["href"] list_url = nextpage[0]["href"]
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