Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VenJob
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Đường Sỹ Hoàng
VenJob
Commits
bacb7c56
Commit
bacb7c56
authored
Dec 11, 2019
by
Đường Sỹ Hoàng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error handler
parent
86bdeff2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
24 deletions
+17
-24
db/schema.rb
+1
-3
lib/tasks/import_job_csv.rake
+16
-21
No files found.
db/schema.rb
View file @
bacb7c56
...
@@ -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:
2019_12_
10_035904
)
do
ActiveRecord
::
Schema
.
define
(
version:
2019_12_
05_082359
)
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"
...
@@ -66,8 +66,6 @@ ActiveRecord::Schema.define(version: 2019_12_10_035904) do
...
@@ -66,8 +66,6 @@ ActiveRecord::Schema.define(version: 2019_12_10_035904) do
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
.
string
"code"
t
.
string
"location"
t
.
string
"company_name"
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
|
...
...
lib/tasks/import_job_csv.rake
View file @
bacb7c56
require
"csv"
require
"csv"
namespace
:
import_job_csv
do
namespace
:
job
do
desc
"Import CSV file into database"
desc
"Import CSV file into database"
task
import_
job
: :environment
do
task
import_
csv
: :environment
do
CSV
.
foreach
(
"db/Venjob.csv"
,
headers:
true
)
do
|
row
|
CSV
.
foreach
(
"db/Venjob.csv"
,
headers:
true
)
do
|
row
|
company_params
=
{
company_params
=
{
email:
row
[
"
C
ontact email"
],
email:
row
[
"
c
ontact email"
],
name:
row
[
"
C
ompany name"
],
name:
row
[
"
c
ompany name"
],
address:
row
[
"
C
ompany address"
],
address:
row
[
"
c
ompany address"
],
code:
row
[
"
C
ompany id"
]
code:
row
[
"
c
ompany id"
]
}
}
Company
.
create!
(
company_params
)
Company
.
create!
(
company_params
)
rescue
import_company_logger
=
ActiveSupport
::
Logger
.
new
(
"log/import_company.log"
)
import_company_logger
.
info
"Skip
#{
row
}
"
next
job_params
=
{
job_params
=
{
company_id:
Company
.
find_by
(
code:
row
[
"Company id"
]).
id
,
company_id:
Company
.
find_by
(
code:
row
[
"company id"
]).
id
,
location:
row
[
"Work place"
],
title:
row
[
"name"
],
title:
row
[
"Name"
],
description:
row
[
"description"
],
description:
row
[
"Description"
],
position:
row
[
"level"
],
position:
row
[
"Level"
],
salary:
row
[
"salary"
],
salary:
row
[
"Salary"
],
requirement:
row
[
"requirement"
]
requirement:
row
[
"Requirement"
]
}
}
Job
.
create!
(
job_params
)
Job
.
create!
(
job_params
)
rescue
import_company_logger
=
ActiveSupport
::
Logger
.
new
(
"log/import_job.log"
)
import_company_logger
.
info
"Skip
#{
row
}
"
next
end
end
rescue
import_logger
=
ActiveSupport
::
Logger
.
new
(
"log/import.log"
)
import_logger
.
info
"Skip
#{
row
}
"
next
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment