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
0
Merge Requests
0
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
Nguyen Ngoc Nghia
VeNJOB
Commits
c8e409c0
Commit
c8e409c0
authored
Dec 13, 2019
by
nnnghia98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created data to industry_jobs
parent
56d05385
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
3 deletions
+17
-3
app/models/city.rb
+1
-3
app/models/industry.rb
+2
-0
app/models/job.rb
+3
-0
app/services/jobs_import.rb
+11
-0
No files found.
app/models/city.rb
View file @
c8e409c0
...
...
@@ -17,8 +17,6 @@ class City < ApplicationRecord
has_many
:city_jobs
has_many
:jobs
,
through: :city_jobs
scope
:vn_cities
,
->
{
where
region:
"Việt Nam"
}
do
where
(
name:
"16"
)
puts
"Other"
end
scope
:vn_cities
,
->
{
where
region:
"Việt Nam"
}
scope
:inter_cities
,
->
{
where
region:
"#"
}
end
app/models/industry.rb
View file @
c8e409c0
...
...
@@ -13,4 +13,6 @@
#
class
Industry
<
ApplicationRecord
has_many
:industry_jobs
has_many
:jobs
,
through: :industry_jobs
end
app/models/job.rb
View file @
c8e409c0
...
...
@@ -33,4 +33,7 @@ class Job < ApplicationRecord
has_many
:city_jobs
has_many
:cities
,
through: :city_jobs
has_many
:industry_jobs
has_many
:industries
,
through: :industry_jobs
end
app/services/jobs_import.rb
View file @
c8e409c0
...
...
@@ -6,10 +6,13 @@ class JobsImport
job_columns
=
[
:title
,
:level
,
:salary
,
:description
,
:short_des
,
:requirement
,
:category
,
:company_id
]
city_jobs
=
[]
industry_jobs
=
[]
CSV
.
foreach
(
Rails
.
root
.
join
(
"lib"
,
"jobss.csv"
),
headers:
true
)
do
|
row
|
job_csv
=
JobCsv
.
new
(
row
)
jobs
<<
job_csv
.
csv_attributes
city_jobs
<<
[
row
[
"company province"
],
job_csv
.
title
,
job_csv
.
company_id
]
industry_jobs
<<
[
row
[
"category"
],
job_csv
.
title
,
job_csv
.
company_id
]
end
Job
.
import
job_columns
,
jobs
...
...
@@ -20,5 +23,13 @@ class JobsImport
city
=
City
.
find_by
(
name:
city_name
)
job
.
city_jobs
.
create
(
city_id:
city
.
id
)
end
puts
"Have data in city_jobs table"
industry_jobs
.
each
do
|
industry_name
,
job_title
,
company_id
|
job
=
Job
.
find_by
(
title:
job_title
,
company_id:
company_id
)
industry
=
Industry
.
find_by
(
name:
industry_name
)
job
.
industry_jobs
.
create
(
industry_id:
industry
.
id
)
end
puts
"Have data in industry_jobs table"
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