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
57c5bab7
Commit
57c5bab7
authored
Dec 11, 2019
by
Đường Sỹ Hoàng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added rescue
parent
09737968
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
17 deletions
+19
-17
db/migrate/20191210035904_add_columns_to_job.rb
+0
-6
lib/tasks/import_job_csv.rake
+19
-11
No files found.
db/migrate/20191210035904_add_columns_to_job.rb
deleted
100644 → 0
View file @
09737968
class
AddColumnsToJob
<
ActiveRecord
::
Migration
[
6.0
]
def
change
add_column
:jobs
,
:location
,
:string
add_column
:jobs
,
:company_name
,
:string
end
end
lib/tasks/import_job_csv.rake
View file @
57c5bab7
...
@@ -5,22 +5,30 @@ namespace :import_job_csv do
...
@@ -5,22 +5,30 @@ namespace :import_job_csv do
task
import_job: :environment
do
task
import_job: :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
[
"
c
ompany id"
]).
id
,
company_id:
Company
.
find_by
(
code:
row
[
"
C
ompany id"
]).
id
,
location:
row
[
"
work
place"
],
location:
row
[
"
Work
place"
],
title:
row
[
"
n
ame"
],
title:
row
[
"
N
ame"
],
description:
row
[
"
d
escription"
],
description:
row
[
"
D
escription"
],
position:
row
[
"
l
evel"
],
position:
row
[
"
L
evel"
],
salary:
row
[
"
s
alary"
],
salary:
row
[
"
S
alary"
],
requirement:
row
[
"
r
equirement"
]
requirement:
row
[
"
R
equirement"
]
}
}
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
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