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
11ade7cf
Commit
11ade7cf
authored
Dec 17, 2019
by
nnnghia98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setting file csv path
parent
b0557443
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
6 deletions
+15
-6
app/models/city.rb
+1
-1
app/services/import.rb
+7
-1
app/services/jobs_import.rb
+3
-3
config/settings.yml
+3
-0
lib/tasks/task.rake
+1
-1
No files found.
app/models/city.rb
View file @
11ade7cf
...
...
@@ -21,6 +21,6 @@ class City < ApplicationRecord
scope
:inter_cities
,
->
{
where
region:
"#"
}
def
job_count
jobs
.
count
@job_count
||=
jobs
.
count
end
end
app/services/import.rb
View file @
11ade7cf
require
"csv"
class
Import
def
initialize
(
params
=
{})
end
def
import
cities
=
[]
companies
=
[]
...
...
@@ -10,7 +14,9 @@ class Import
company_columns
=
[
:name
,
:email
,
:address
,
:code
]
industry_columns
=
[
:name
]
CSV
.
foreach
(
Rails
.
root
.
join
(
"lib"
,
"jobss.csv"
),
headers:
true
)
do
|
row
|
file_path
=
Settings
.
csv
.
file_path
CSV
.
foreach
(
Rails
.
root
.
join
(
"lib"
,
file_path
),
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"
]}
...
...
app/services/jobs_import.rb
View file @
11ade7cf
...
...
@@ -7,7 +7,9 @@ class JobsImport
:requirement
,
:category
,
:company_id
]
join_jobs
=
[]
CSV
.
foreach
(
Rails
.
root
.
join
(
"lib"
,
"jobss.csv"
),
headers:
true
)
do
|
row
|
file_path
=
Settings
.
csv
.
file_path
CSV
.
foreach
(
Rails
.
root
.
join
(
"lib"
,
file_path
),
headers:
true
)
do
|
row
|
job_csv
=
JobCsv
.
new
(
row
)
jobs
<<
job_csv
.
csv_attributes
join_jobs
<<
[
row
[
"company province"
],
row
[
"category"
],
job_csv
.
title
,
job_csv
.
company_id
]
...
...
@@ -22,7 +24,5 @@ class JobsImport
industry
=
Industry
.
find_by
(
name:
industry_name
)
job
.
industry_jobs
.
create
(
industry_id:
industry
.
id
)
end
puts
"See import.log for more details."
end
end
config/settings.yml
View file @
11ade7cf
job
:
per_page
:
5
csv
:
file_path
:
"
jobss.csv"
lib/tasks/task.rake
View file @
11ade7cf
...
...
@@ -5,6 +5,6 @@ namespace :task do
JobsImport
.
new
.
import_job
import
=
ActiveSupport
::
Logger
.
new
(
"log/import.log"
)
import
.
debug
"Cities, industries, companies, jobs imported:
#{
Time
.
current
}
"
import
.
info
"Cities, industries, companies, jobs imported:
#{
Time
.
current
}
"
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