Commit f7eb9e0f by Son Do Hong

Merge branch 'feature/import_data' into 'master'

Feature/import data

See merge request !6
parents f1acce90 0f5b554b
...@@ -29,3 +29,7 @@ ...@@ -29,3 +29,7 @@
/yarn-error.log /yarn-error.log
yarn-debug.log* yarn-debug.log*
.yarn-integrity .yarn-integrity
config/settings.local.yml
config/settings/*.local.yml
config/environments/*.local.yml
...@@ -24,6 +24,8 @@ gem 'kaminari' ...@@ -24,6 +24,8 @@ gem 'kaminari'
gem 'sunspot_rails' gem 'sunspot_rails'
gem 'sunspot_solr' gem 'sunspot_solr'
gem 'devise' gem 'devise'
gem 'activerecord-import'
gem 'config'
# Use Redis adapter to run Action Cable in production # Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0' # gem 'redis', '~> 4.0'
# Use Active Model has_secure_password # Use Active Model has_secure_password
...@@ -38,6 +40,8 @@ gem 'bootsnap', '>= 1.4.2', require: false ...@@ -38,6 +40,8 @@ gem 'bootsnap', '>= 1.4.2', require: false
group :development, :test do group :development, :test do
# 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'
gem 'annotate'
end end
group :development do group :development do
......
...@@ -45,6 +45,8 @@ GEM ...@@ -45,6 +45,8 @@ GEM
activerecord (6.0.1) activerecord (6.0.1)
activemodel (= 6.0.1) activemodel (= 6.0.1)
activesupport (= 6.0.1) activesupport (= 6.0.1)
activerecord-import (1.0.3)
activerecord (>= 3.2)
activestorage (6.0.1) activestorage (6.0.1)
actionpack (= 6.0.1) actionpack (= 6.0.1)
activejob (= 6.0.1) activejob (= 6.0.1)
...@@ -58,6 +60,9 @@ GEM ...@@ -58,6 +60,9 @@ GEM
zeitwerk (~> 2.2) zeitwerk (~> 2.2)
addressable (2.7.0) addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
annotate (3.0.3)
activerecord (>= 3.2, < 7.0)
rake (>= 10.4, < 14.0)
bcrypt (3.1.13) bcrypt (3.1.13)
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.4.5) bootsnap (1.4.5)
...@@ -80,14 +85,50 @@ GEM ...@@ -80,14 +85,50 @@ GEM
mimemagic (>= 0.3.0) mimemagic (>= 0.3.0)
mini_mime (>= 0.1.3) mini_mime (>= 0.1.3)
childprocess (3.0.0) childprocess (3.0.0)
coderay (1.1.2)
concurrent-ruby (1.1.5) concurrent-ruby (1.1.5)
config (2.0.0)
activesupport (>= 4.2)
deep_merge (~> 1.2, >= 1.2.1)
dry-schema (~> 1.0)
crass (1.0.5) crass (1.0.5)
deep_merge (1.2.1)
devise (4.7.1) devise (4.7.1)
bcrypt (~> 3.0) bcrypt (~> 3.0)
orm_adapter (~> 0.1) orm_adapter (~> 0.1)
railties (>= 4.1.0) railties (>= 4.1.0)
responders responders
warden (~> 1.2.3) warden (~> 1.2.3)
dry-configurable (0.9.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.4, >= 0.4.7)
dry-container (0.7.2)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (0.4.9)
concurrent-ruby (~> 1.0)
dry-equalizer (0.3.0)
dry-inflector (0.2.0)
dry-initializer (3.0.2)
dry-logic (1.0.5)
concurrent-ruby (~> 1.0)
dry-core (~> 0.2)
dry-equalizer (~> 0.2)
dry-schema (1.4.1)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.8, >= 0.8.3)
dry-core (~> 0.4)
dry-equalizer (~> 0.2)
dry-initializer (~> 3.0)
dry-logic (~> 1.0)
dry-types (~> 1.2)
dry-types (1.2.1)
concurrent-ruby (~> 1.0)
dry-container (~> 0.3)
dry-core (~> 0.4, >= 0.4.4)
dry-equalizer (~> 0.2, >= 0.2.2)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 1.0, >= 1.0.2)
erubi (1.9.0) erubi (1.9.0)
faraday (0.17.1) faraday (0.17.1)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
...@@ -142,6 +183,9 @@ GEM ...@@ -142,6 +183,9 @@ GEM
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0) orm_adapter (0.5.0)
pr_geohash (1.0.0) pr_geohash (1.0.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (4.0.1) public_suffix (4.0.1)
puma (3.12.1) puma (3.12.1)
rack (2.0.7) rack (2.0.7)
...@@ -256,16 +300,20 @@ PLATFORMS ...@@ -256,16 +300,20 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
activerecord-import
annotate
bootsnap (>= 1.4.2) bootsnap (>= 1.4.2)
byebug byebug
capybara (>= 2.15) capybara (>= 2.15)
carrierwave carrierwave
config
devise devise
jbuilder jbuilder
jquery-rails (= 4.3.1) jquery-rails (= 4.3.1)
kaminari kaminari
listen (>= 3.0.5, < 3.2) listen (>= 3.0.5, < 3.2)
mysql2 (>= 0.4.4) mysql2 (>= 0.4.4)
pry
puma (~> 3.11) puma (~> 3.11)
rails (~> 6.0.0) rails (~> 6.0.0)
sass-rails (~> 5) sass-rails (~> 5)
......
...@@ -14,7 +14,7 @@ $light-gray: #777; ...@@ -14,7 +14,7 @@ $light-gray: #777;
/* universal */ /* universal */
body { body {
padding-top: 30px; padding-top: 90px;
} }
section { section {
...@@ -32,6 +32,33 @@ textarea { ...@@ -32,6 +32,33 @@ textarea {
} }
} }
/* typography */
h1, h2, h3, h4, h5, h6 {
line-height: 1;
}
h1 {
font-size: 3em;
letter-spacing: -2px;
margin-bottom: 30px;
text-align: center;
}
h2 {
font-size: 1.2em;
letter-spacing: -1px;
margin-bottom: 30px;
text-align: center;
font-weight: normal;
color: $light-gray;
}
p {
font-size: 1.1em;
line-height: 1.7em;
}
/* header */ /* header */
/* footer */ /* footer */
...@@ -50,3 +77,13 @@ footer { ...@@ -50,3 +77,13 @@ footer {
} }
} }
} }
/* miscellaneous */
.debug_dump {
clear: both;
float: left;
width: 100%;
margin-top: 45px;
@include box_sizing;
}
class CitiesController < ApplicationController
def index
@cities = City.all
end
end
class CompaniesController < ApplicationController
def index
@companies = Company.all
end
end
class IndustriesController < ApplicationController
def index
@industries = Industry.all
end
end
class JobsController < ApplicationController
def index
@jobs = Job.all
end
end
class StaticPagesController < ApplicationController class StaticPagesController < ApplicationController
def index def index
@cities = City.all
@industries = Industry.all
@jobs = Job.page(params[:page]).per(Settings.jobs.page.per)
end end
end end
# == Schema Information
#
# Table name: cities
#
# id :bigint not null, primary key
# name :string(255)
# region :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_cities_on_name (name) UNIQUE
#
class City < ApplicationRecord class City < ApplicationRecord
end end
# == Schema Information
#
# Table name: city_jobs
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# city_id :bigint
# job_id :bigint
#
# Indexes
#
# index_city_jobs_on_city_id (city_id)
# index_city_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (city_id => cities.id)
# fk_rails_... (job_id => jobs.id)
#
class CityJob < ApplicationRecord class CityJob < ApplicationRecord
belongs_to :city belongs_to :city
belongs_to :job belongs_to :job
......
# == Schema Information
#
# Table name: companies
#
# id :bigint not null, primary key
# address :string(255)
# code :string(255)
# description :text(65535)
# email :string(255)
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_companies_on_code (code) UNIQUE
# index_companies_on_email (email) UNIQUE
#
class Company < ApplicationRecord class Company < ApplicationRecord
has_many :jobs, dependent: :destroy
end end
# == Schema Information
#
# Table name: crawl_urls
#
# id :bigint not null, primary key
# crawled :boolean default(FALSE)
# title :string(255)
# url :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class CrawlUrl < ApplicationRecord class CrawlUrl < ApplicationRecord
end end
# == Schema Information
#
# Table name: industries
#
# id :bigint not null, primary key
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_industries_on_name (name) UNIQUE
#
class Industry < ApplicationRecord class Industry < ApplicationRecord
end end
# == Schema Information
#
# Table name: industry_jobs
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# industry_id :bigint
# job_id :bigint
#
# Indexes
#
# index_industry_jobs_on_industry_id (industry_id)
# index_industry_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (industry_id => industries.id)
# fk_rails_... (job_id => jobs.id)
#
class IndustryJob < ApplicationRecord class IndustryJob < ApplicationRecord
belongs_to :industry belongs_to :industry
belongs_to :job belongs_to :job
......
# == Schema Information
#
# Table name: jobs
#
# id :bigint not null, primary key
# category :integer
# code :string(255)
# description :text(65535)
# expiration_date :datetime
# level :string(255)
# other_salary :string(255)
# post_date :datetime
# requirement :text(65535)
# salary :string(255)
# short_des :text(65535)
# title :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# company_id :bigint
#
# Indexes
#
# index_jobs_on_code (code) UNIQUE
# index_jobs_on_company_id (company_id)
#
# Foreign Keys
#
# fk_rails_... (company_id => companies.id)
#
class Job < ApplicationRecord class Job < ApplicationRecord
belongs_to :company belongs_to :company
end end
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# activated :boolean
# confirmation_token :string(255)
# confirmed_at :datetime
# cv_path :string(255)
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# first_name :string(255)
# last_name :string(255)
# remember_created_at :datetime
# remember_digest :string(255)
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# role :integer
# username :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_email (email) UNIQUE
# index_users_on_reset_password_token (reset_password_token) UNIQUE
# index_users_on_username (username) UNIQUE
#
class User < ApplicationRecord class User < ApplicationRecord
# Include default devise modules. Others available are: # Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
......
# == Schema Information
#
# Table name: user_jobs
#
# id :bigint not null, primary key
# applied_at :datetime
# favorited_at :datetime
# viewed_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# job_id :bigint
# user_id :bigint
#
# Indexes
#
# index_user_jobs_on_job_id (job_id)
# index_user_jobs_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (job_id => jobs.id)
# fk_rails_... (user_id => users.id)
#
class UserJob < ApplicationRecord class UserJob < ApplicationRecord
belongs_to :user belongs_to :user
belongs_to :job belongs_to :job
......
require "csv"
class Import
def import
cities = []
companies = []
industries = []
city_columns = [:name, :region]
company_columns = [:name, :email, :address, :code]
industry_columns = [:name]
CSV.foreach(Rails.root.join("lib", "jobss.csv"), headers: true) do |row|
cities << {name: row["company province"], region: "Việt Nam"}
companies << {name: row["company name"], email: row["contact email"],
address: row["company address"], code: row["company id"]}
industries << {name: row["category"]}
end
City.import city_columns, cities, on_duplicate_key_ignore: true
puts "Cities imported"
Company.import company_columns, companies, on_duplicate_key_ignore: true
puts "Companies imported"
Industry.import industry_columns, industries, on_duplicate_key_ignore: true
puts "Industries imported"
end
end
class JobCsv
def initialize(row)
@row = row
end
def title
@title ||= @row["name"]
end
def level
@level ||= @row["level"]
end
def salary
@salary ||= @row["salary"]
end
def description
@description ||= @row["description"]
end
def short_des
@short_des ||= @row["benefit"]
end
def requirement
@requirement ||= @row["requirement"]
end
def category
@category ||= @row["type"]
end
def company_id
@company_id ||= company.id
end
def company
@company ||= Company.find_by(code: @row["company id"]) ||
Company.create(name: @row["company name"], email: @row["contact email"],
address: @row["company address"],
code: @row["company id"])
end
def csv_attributes
{title: title, level: level, salary: salary, description: description,
short_des: short_des, requirement: requirement, category: category,
company_id: company_id}
end
end
require "csv"
class JobsImport
def import_job
jobs = []
job_columns = [:title, :level, :salary, :description, :short_des,
:requirement, :category, :company_id]
CSV.foreach(Rails.root.join("lib", "jobss.csv"), headers: true) do |row|
jobs << JobCsv.new(row).csv_attributes
end
Job.import job_columns, jobs
puts "Jobs imported"
end
end
<li class="list-group-item"><%= city.name %></li>
<%= render partial: "cities/city", collection: @cities %>
<tr>
<td><%= company.name %></td>
<td><%= company.email %></td>
<td><%= company.address %></td>
</tr>
<table class="table">
<tbody>
<ul class="table">
<%= render partial: "companies/company", collection: @companies %>
</ul>
</tbody>
</table>
<li class="list-group-item"><%= industry.name %></li>
<%= render partial: "industries/industry", collection: @industries %>
<tr>
<td><%= job.title %></td>
<td><%= job.short_des %></td>
<td><%= job.salary %></td>
</tr>
<%= render partial: "jobs/job", collection: @jobs %>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<nav> <nav>
<ul> <ul>
<li>ZIGExN VeNtura</li> <li>ZIGExN VeNtura</li>
<li><%= Time.now.year %></li> <li><%= Time.current.year %></li>
</ul> </ul>
</nav> </nav>
</footer> </footer>
<header class="navbar navbar-fixed-top navbar-inverse navbar-dark bg-dark"> <header class="navbar fixed-top navbar-dark bg-dark">
<div class="container"> <div class="container">
<%= link_to image_tag("venjob_logo.png", alt: "VeNJOB Logo") , root_path, id: "logo" %> <%= link_to image_tag("venjob_logo.png", alt: "VeNJOB Logo") , root_path, id: "logo" %>
<nav> <nav>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<ul class="list"> <ul class="list">
<li class="list-item"> <% if user_signed_in? %>
Logged in as <strong><%= current_user.email %></strong>.
<li class="list-inline-item"></li><%= link_to "My Page", "#" %></li>
<li class="list-inline-item"></li><%= link_to "Logout", "#" %></li>
<% else %>
<li class="list-inline-item"><%= link_to "Login", "#" %></li> <li class="list-inline-item"><%= link_to "Login", "#" %></li>
<li class="list-inline-item"><%= link_to "Register", "#" %></li> <li class="list-inline-item"><%= link_to "Register", "#" %></li>
</li> <% end %>
<li class="list-item">
<li class="list-inline-item"><%= link_to "Favorite", "#" %></li> <li class="list-inline-item"><%= link_to "Favorite", "#" %></li>
<li class="list-inline-item"><%= link_to "History", "#" %></li> <li class="list-inline-item"><%= link_to "History", "#" %></li>
</li>
</ul> </ul>
</ul> </ul>
</nav> </nav>
......
<h1>VeNJOB Top page</h1> <% provide(:title, "Top Page") %>
<div class="container"> <div class="center jumbotron">
<div class="banner"> <div class="banner">
<img src="banner.png" alt="Banner">
</div>
<div class="search"></div>
<div class="lastest_jobs">
<h3>Latest jobs</h3>
<table class="table">
<tbody>
<ul class="table">
<%= render partial: "jobs/job", collection: @jobs %>
</ul>
</tbody>
</table>
<%= paginate @jobs %>
</div>
<div class="top_cities">
<h3>Top cities</h3>
<ul class="list-group list-group-horizontal">
<%= render partial: "cities/city", collection: @cities %>
</ul>
</div>
<div class="top_industries">
<h3>Top industries</h3>
<ul class="list-group list-group-horizontal">
<%= render partial: "industries/industry", collection: @industries %>
</ul>
</div> </div>
</div> </div>
Config.setup do |config|
# Name of the constant exposing loaded settings
config.const_name = 'Settings'
# Ability to remove elements of the array set in earlier loaded settings file. For example value: '--'.
#
# config.knockout_prefix = nil
# Overwrite an existing value when merging a `nil` value.
# When set to `false`, the existing value is retained after merge.
#
# config.merge_nil_values = true
# Overwrite arrays found in previously loaded settings file. When set to `false`, arrays will be merged.
#
# config.overwrite_arrays = true
# Load environment variables from the `ENV` object and override any settings defined in files.
#
# config.use_env = false
# Define ENV variable prefix deciding which variables to load into config.
#
# config.env_prefix = 'Settings'
# What string to use as level separator for settings loaded from ENV variables. Default value of '.' works well
# with Heroku, but you might want to change it for example for '__' to easy override settings from command line, where
# using dots in variable names might not be allowed (eg. Bash).
#
# config.env_separator = '.'
# Ability to process variables names:
# * nil - no change
# * :downcase - convert to lower case
#
# config.env_converter = :downcase
# Parse numeric values as integers instead of strings.
#
# config.env_parse_values = true
# Validate presence and type of specific config values. Check https://github.com/dry-rb/dry-validation for details.
#
# config.schema do
# required(:name).filled
# required(:age).maybe(:int?)
# required(:email).filled(format?: EMAIL_REGEX)
# end
end
Rails.application.routes.draw do Rails.application.routes.draw do
resources :companies, only: :index
resources :industries, only: :index
resources :cities, only: :index
resources :jobs, only: :index
devise_for :users devise_for :users
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root "static_pages#index" root "static_pages#index"
get "static_pages/index" get "static_pages/index"
end end
jobs:
page:
per: 5
class CreateIndustries < ActiveRecord::Migration[6.0] class CreateIndustries < ActiveRecord::Migration[6.0]
def change def change
create_table :industries do |t| create_table :industries do |t|
t.string :name t.string :name, unique: true
t.timestamps t.timestamps
end end
add_index :industries, :name, unique: true
end end
end end
...@@ -11,7 +11,7 @@ class CreateJobs < ActiveRecord::Migration[6.0] ...@@ -11,7 +11,7 @@ class CreateJobs < ActiveRecord::Migration[6.0]
t.integer :category t.integer :category
t.datetime :post_date t.datetime :post_date
t.datetime :expiration_date t.datetime :expiration_date
t.references :company, null: false, foreign_key: true t.references :company, foreign_key: true
t.timestamps t.timestamps
end end
......
class CreateUserJobs < ActiveRecord::Migration[6.0] class CreateUserJobs < ActiveRecord::Migration[6.0]
def change def change
create_table :user_jobs do |t| create_table :user_jobs do |t|
t.references :user, null: false, foreign_key: true t.references :user, foreign_key: true
t.references :job, null: false, foreign_key: true t.references :job, foreign_key: true
t.datetime :applied_at t.datetime :applied_at
t.datetime :viewed_at t.datetime :viewed_at
t.datetime :favorited_at t.datetime :favorited_at
......
class CreateCityJobs < ActiveRecord::Migration[6.0] class CreateCityJobs < ActiveRecord::Migration[6.0]
def change def change
create_table :city_jobs do |t| create_table :city_jobs do |t|
t.references :city, null: false, foreign_key: true t.references :city, foreign_key: true
t.references :job, null: false, foreign_key: true t.references :job, foreign_key: true
t.timestamps t.timestamps
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.references :industry, null: false, foreign_key: true t.references :industry, foreign_key: true
t.references :job, null: false, foreign_key: true t.references :job, foreign_key: true
t.timestamps t.timestamps
end end
......
class AddCompanyCodeToCompany < ActiveRecord::Migration[6.0]
def change
add_column :companies, :code, :string, unique: true
add_index :companies, :code, unique: true
end
end
class AddCodeToJob < ActiveRecord::Migration[6.0]
def change
add_column :jobs, :code, :string, unique: true
add_index :jobs, :code, unique: true
end
end
...@@ -10,18 +10,19 @@ ...@@ -10,18 +10,19 @@
# #
# 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: 2019_11_26_083335) do ActiveRecord::Schema.define(version: 2019_12_05_090113) do
create_table "cities", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "cities", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "name" t.string "name"
t.string "region" t.string "region"
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 ["name"], name: "index_cities_on_name", unique: true
end end
create_table "city_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "city_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.bigint "city_id", null: false t.bigint "city_id"
t.bigint "job_id", null: false t.bigint "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
t.index ["city_id"], name: "index_city_jobs_on_city_id" t.index ["city_id"], name: "index_city_jobs_on_city_id"
...@@ -35,6 +36,9 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do ...@@ -35,6 +36,9 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
t.string "address" t.string "address"
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.string "code"
t.index ["code"], name: "index_companies_on_code", unique: true
t.index ["email"], name: "index_companies_on_email", unique: true
end end
create_table "crawl_urls", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "crawl_urls", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
...@@ -49,11 +53,12 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do ...@@ -49,11 +53,12 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
t.string "name" t.string "name"
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 ["name"], name: "index_industries_on_name", unique: true
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.bigint "industry_id", null: false t.bigint "industry_id"
t.bigint "job_id", null: false t.bigint "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
t.index ["industry_id"], name: "index_industry_jobs_on_industry_id" t.index ["industry_id"], name: "index_industry_jobs_on_industry_id"
...@@ -71,15 +76,17 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do ...@@ -71,15 +76,17 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
t.integer "category" t.integer "category"
t.datetime "post_date" t.datetime "post_date"
t.datetime "expiration_date" t.datetime "expiration_date"
t.bigint "company_id", null: false t.bigint "company_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
t.string "code"
t.index ["code"], name: "index_jobs_on_code", unique: true
t.index ["company_id"], name: "index_jobs_on_company_id" t.index ["company_id"], name: "index_jobs_on_company_id"
end end
create_table "user_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| create_table "user_jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.bigint "user_id", null: false t.bigint "user_id"
t.bigint "job_id", null: false t.bigint "job_id"
t.datetime "applied_at" t.datetime "applied_at"
t.datetime "viewed_at" t.datetime "viewed_at"
t.datetime "favorited_at" t.datetime "favorited_at"
......
,nghiann,devops-OptiPlex-3020,02.12.2019 09:27,file:///home/nghiann/.config/libreoffice/4;
\ No newline at end of file
This diff is collapsed. Click to expand it.
# NOTE: only doing this in development as some production environments (Heroku)
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
# NOTE: to have a dev-mode tool do its thing in production.
if Rails.env.development?
require 'annotate'
task :set_annotation_options do
# You can override any of these by setting an environment variable of the
# same name.
Annotate.set_defaults(
'additional_file_patterns' => [],
'routes' => 'false',
'models' => 'true',
'position_in_routes' => 'before',
'position_in_class' => 'before',
'position_in_test' => 'before',
'position_in_fixture' => 'before',
'position_in_factory' => 'before',
'position_in_serializer' => 'before',
'show_foreign_keys' => 'true',
'show_complete_foreign_keys' => 'false',
'show_indexes' => 'true',
'simple_indexes' => 'false',
'model_dir' => 'app/models',
'root_dir' => '',
'include_version' => 'false',
'require' => '',
'exclude_tests' => 'false',
'exclude_fixtures' => 'false',
'exclude_factories' => 'false',
'exclude_serializers' => 'false',
'exclude_scaffolds' => 'true',
'exclude_controllers' => 'true',
'exclude_helpers' => 'true',
'exclude_sti_subclasses' => 'false',
'ignore_model_sub_dir' => 'false',
'ignore_columns' => nil,
'ignore_routes' => nil,
'ignore_unknown_models' => 'false',
'hide_limit_column_types' => 'integer,bigint,boolean',
'hide_default_column_types' => 'json,jsonb,hstore',
'skip_on_db_migrate' => 'false',
'format_bare' => 'true',
'format_rdoc' => 'false',
'format_markdown' => 'false',
'sort' => 'false',
'force' => 'false',
'frozen' => 'false',
'classified_sort' => 'true',
'trace' => 'false',
'wrapper_open' => nil,
'wrapper_close' => nil,
'with_comment' => 'true'
)
end
Annotate.load_tasks
end
namespace :task do
desc "import data"
task import: :environment do
Import.new.import
JobsImport.new.import_job
end
end
require 'test_helper'
class CitiesControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get cities_index_url
assert_response :success
end
end
require 'test_helper'
class CompaniesControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get companies_index_url
assert_response :success
end
end
require 'test_helper'
class IndustriesControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get industries_index_url
assert_response :success
end
end
require 'test_helper'
class JobsControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get jobs_index_url
assert_response :success
end
end
require 'test_helper' require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest class StaticPagesControllerTest < ActionDispatch::IntegrationTest
test "should get top_page" do def setup
get root_path @base_title = "VeNJOB"
assert_response :success
assert_select "title", "VeNJOB"
end
test "should get favorite" do
get favorite_url
assert_response :success
assert_select "title", "Favorite | VeNJOB"
end end
test "should get history" do test "should get top_page" do
get history_url get root_path
assert_response :success assert_response :success
assert_select "title", "History | VeNJOB" assert_select "title", "Top Page | #{@base_title}"
end end
end end
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # == Schema Information
#
one: # Table name: cities
name: MyString #
region: MyString # id :bigint not null, primary key
# name :string(255)
# region :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_cities_on_name (name) UNIQUE
#
two: # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
name: MyString
region: MyString
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # == Schema Information
#
one: # Table name: city_jobs
city: one #
job: one # id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# city_id :bigint
# job_id :bigint
#
# Indexes
#
# index_city_jobs_on_city_id (city_id)
# index_city_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (city_id => cities.id)
# fk_rails_... (job_id => jobs.id)
#
two: # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
city: two
job: two
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # == Schema Information
#
# Table name: companies
#
# id :bigint not null, primary key
# address :string(255)
# code :string(255)
# description :text(65535)
# email :string(255)
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_companies_on_code (code) UNIQUE
# index_companies_on_email (email) UNIQUE
#
one:
name: MyString
email: MyString
description: MyText
address: MyString
two:
name: MyString
email: MyString
description: MyText
address: MyString
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # == Schema Information
#
one: # Table name: crawl_urls
url: MyString #
title: MyString # id :bigint not null, primary key
crawled: false # crawled :boolean default(FALSE)
# title :string(255)
# url :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
two: # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
url: MyString
title: MyString
crawled: false
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # == Schema Information
#
one: # Table name: industries
name: MyString #
# id :bigint not null, primary key
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_industries_on_name (name) UNIQUE
#
two: # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
name: MyString
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # == Schema Information
#
one: # Table name: industry_jobs
industry: one #
job: one # id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# industry_id :bigint
# job_id :bigint
#
# Indexes
#
# index_industry_jobs_on_industry_id (industry_id)
# index_industry_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (industry_id => industries.id)
# fk_rails_... (job_id => jobs.id)
#
two: # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
industry: two
job: two
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # == Schema Information
#
one: # Table name: jobs
title: MyString #
level: MyString # id :bigint not null, primary key
salary: MyString # category :integer
other_salary: MyString # code :string(255)
description: MyText # description :text(65535)
short_des: MyText # expiration_date :datetime
requirement: MyText # level :string(255)
category: 1 # other_salary :string(255)
post_date: 2019-11-26 15:31:10 # post_date :datetime
expiration_date: 2019-11-26 15:31:10 # requirement :text(65535)
company: one # salary :string(255)
# short_des :text(65535)
# title :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# company_id :bigint
#
# Indexes
#
# index_jobs_on_code (code) UNIQUE
# index_jobs_on_company_id (company_id)
#
# Foreign Keys
#
# fk_rails_... (company_id => companies.id)
#
two: # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
title: MyString
level: MyString
salary: MyString
other_salary: MyString
description: MyText
short_des: MyText
requirement: MyText
category: 1
post_date: 2019-11-26 15:31:10
expiration_date: 2019-11-26 15:31:10
company: two
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # == Schema Information
#
one: # Table name: user_jobs
user: one #
job: one # id :bigint not null, primary key
applied_at: 2019-11-26 15:31:51 # applied_at :datetime
relation: 1 # favorited_at :datetime
# viewed_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# job_id :bigint
# user_id :bigint
#
# Indexes
#
# index_user_jobs_on_job_id (job_id)
# index_user_jobs_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (job_id => jobs.id)
# fk_rails_... (user_id => users.id)
#
two: # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
user: two
job: two
applied_at: 2019-11-26 15:31:51
relation: 1
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html # == Schema Information
#
# This model initially had no columns defined. If you add columns to the # Table name: users
# model remove the '{}' from the fixture names and add the columns immediately #
# below each fixture, per the syntax in the comments below # id :bigint not null, primary key
# activated :boolean
# confirmation_token :string(255)
# confirmed_at :datetime
# cv_path :string(255)
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# first_name :string(255)
# last_name :string(255)
# remember_created_at :datetime
# remember_digest :string(255)
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# role :integer
# username :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# #
one: {} # Indexes
# column: value
# #
two: {} # index_users_on_email (email) UNIQUE
# column: value # index_users_on_reset_password_token (reset_password_token) UNIQUE
# index_users_on_username (username) UNIQUE
#
# == Schema Information
#
# Table name: city_jobs
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# city_id :bigint
# job_id :bigint
#
# Indexes
#
# index_city_jobs_on_city_id (city_id)
# index_city_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (city_id => cities.id)
# fk_rails_... (job_id => jobs.id)
#
require 'test_helper' require 'test_helper'
class CityJobTest < ActiveSupport::TestCase class CityJobTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: cities
#
# id :bigint not null, primary key
# name :string(255)
# region :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_cities_on_name (name) UNIQUE
#
require 'test_helper' require 'test_helper'
class CityTest < ActiveSupport::TestCase class CityTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: companies
#
# id :bigint not null, primary key
# address :string(255)
# code :string(255)
# description :text(65535)
# email :string(255)
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_companies_on_code (code) UNIQUE
# index_companies_on_email (email) UNIQUE
#
require 'test_helper' require 'test_helper'
class CompanyTest < ActiveSupport::TestCase class CompanyTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: crawl_urls
#
# id :bigint not null, primary key
# crawled :boolean default(FALSE)
# title :string(255)
# url :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
require 'test_helper' require 'test_helper'
class CrawlUrlTest < ActiveSupport::TestCase class CrawlUrlTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: industry_jobs
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# industry_id :bigint
# job_id :bigint
#
# Indexes
#
# index_industry_jobs_on_industry_id (industry_id)
# index_industry_jobs_on_job_id (job_id)
#
# Foreign Keys
#
# fk_rails_... (industry_id => industries.id)
# fk_rails_... (job_id => jobs.id)
#
require 'test_helper' require 'test_helper'
class IndustryJobTest < ActiveSupport::TestCase class IndustryJobTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: industries
#
# id :bigint not null, primary key
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_industries_on_name (name) UNIQUE
#
require 'test_helper' require 'test_helper'
class IndustryTest < ActiveSupport::TestCase class IndustryTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: jobs
#
# id :bigint not null, primary key
# category :integer
# code :string(255)
# description :text(65535)
# expiration_date :datetime
# level :string(255)
# other_salary :string(255)
# post_date :datetime
# requirement :text(65535)
# salary :string(255)
# short_des :text(65535)
# title :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# company_id :bigint
#
# Indexes
#
# index_jobs_on_code (code) UNIQUE
# index_jobs_on_company_id (company_id)
#
# Foreign Keys
#
# fk_rails_... (company_id => companies.id)
#
require 'test_helper' require 'test_helper'
class JobTest < ActiveSupport::TestCase class JobTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: user_jobs
#
# id :bigint not null, primary key
# applied_at :datetime
# favorited_at :datetime
# viewed_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# job_id :bigint
# user_id :bigint
#
# Indexes
#
# index_user_jobs_on_job_id (job_id)
# index_user_jobs_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (job_id => jobs.id)
# fk_rails_... (user_id => users.id)
#
require 'test_helper' require 'test_helper'
class UserJobTest < ActiveSupport::TestCase class UserJobTest < ActiveSupport::TestCase
......
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# activated :boolean
# confirmation_token :string(255)
# confirmed_at :datetime
# cv_path :string(255)
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# first_name :string(255)
# last_name :string(255)
# remember_created_at :datetime
# remember_digest :string(255)
# reset_password_sent_at :datetime
# reset_password_token :string(255)
# role :integer
# username :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_email (email) UNIQUE
# index_users_on_reset_password_token (reset_password_token) UNIQUE
# index_users_on_username (username) UNIQUE
#
require 'test_helper' require 'test_helper'
class UserTest < ActiveSupport::TestCase class UserTest < ActiveSupport::TestCase
......
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