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
ae84c4c6
Commit
ae84c4c6
authored
Dec 13, 2019
by
nnnghia98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create record in city_jobs
parent
16ebb07b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
3 deletions
+16
-3
app/models/city.rb
+3
-1
app/models/job.rb
+2
-0
app/services/jobs_import.rb
+10
-2
app/views/cities/_city.html.erb
+1
-0
No files found.
app/models/city.rb
View file @
ae84c4c6
...
@@ -14,7 +14,9 @@
...
@@ -14,7 +14,9 @@
#
#
class
City
<
ApplicationRecord
class
City
<
ApplicationRecord
has_many
:city_jobs
has_many
:jobs
,
through: :city_jobs
scope
:vn_cities
,
->
{
where
region:
"Việt Nam"
}
scope
:vn_cities
,
->
{
where
region:
"Việt Nam"
}
scope
:inter_cities
,
->
{
where
region:
"#"
}
scope
:inter_cities
,
->
{
where
region:
"#"
}
has_many
:city_jobs
end
end
app/models/job.rb
View file @
ae84c4c6
...
@@ -31,4 +31,6 @@
...
@@ -31,4 +31,6 @@
class
Job
<
ApplicationRecord
class
Job
<
ApplicationRecord
belongs_to
:company
belongs_to
:company
has_many
:city_jobs
has_many
:cities
,
through: :city_jobs
has_many
:cities
,
through: :city_jobs
end
app/services/jobs_import.rb
View file @
ae84c4c6
...
@@ -5,12 +5,20 @@ class JobsImport
...
@@ -5,12 +5,20 @@ class JobsImport
jobs
=
[]
jobs
=
[]
job_columns
=
[
:title
,
:level
,
:salary
,
:description
,
:short_des
,
job_columns
=
[
:title
,
:level
,
:salary
,
:description
,
:short_des
,
:requirement
,
:category
,
:company_id
]
:requirement
,
:category
,
:company_id
]
city_jobs
=
[]
CSV
.
foreach
(
Rails
.
root
.
join
(
"lib"
,
"jobss.csv"
),
headers:
true
)
do
|
row
|
CSV
.
foreach
(
Rails
.
root
.
join
(
"lib"
,
"jobss.csv"
),
headers:
true
)
do
|
row
|
jobs
<<
JobCsv
.
new
(
row
).
csv_attributes
job_csv
=
JobCsv
.
new
(
row
)
jobs
<<
job_csv
.
csv_attributes
city_jobs
<<
[
row
[
"company province"
],
job_csv
.
title
,
job_csv
.
company_id
]
end
end
Job
.
import
job_columns
,
jobs
Job
.
import
job_columns
,
jobs
puts
"Jobs imported"
puts
"Jobs imported"
city_jobs
.
each
do
|
city_name
,
job_title
,
company_id
|
job
=
Job
.
find_by
(
title:
job_title
,
company_id:
company_id
)
city
=
City
.
find_by
(
name:
city_name
)
job
.
city_jobs
.
create
(
city_id:
city
.
id
)
end
end
end
end
end
app/views/cities/_city.html.erb
View file @
ae84c4c6
<div
class=
"col-md-3"
>
<div
class=
"col-md-3"
>
<div
class=
"col-show"
>
<div
class=
"col-show"
>
<%=
city
.
name
%>
<%=
city
.
name
%>
<%=
(
city
.
jobs
.
count
)
%>
</div>
</div>
</div>
</div>
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