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
54e0368f
Commit
54e0368f
authored
Mar 02, 2020
by
nnnghia98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass 1 param into save_job
parent
37105061
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
29 deletions
+23
-29
app/services/crawl_data.rb
+11
-18
app/services/job_html.rb
+12
-11
No files found.
app/services/crawl_data.rb
View file @
54e0368f
...
...
@@ -25,6 +25,7 @@ class CrawlData
# Job code
job_code
=
job_url
.
split
(
"/"
).
last
.
split
(
"."
)[
-
2
]
||
""
job
[
:code
]
=
job_code
# Company code
company_code
=
job_page
.
css
(
".viewmorejob a @href"
).
present?
?
...
...
@@ -34,17 +35,16 @@ class CrawlData
job
[
:workplace
].
each
do
|
city_name
|
city_id
=
get_city
(
city_name
).
id
company_id
=
get_company
(
company_code
,
job
[
:company_name
],
job
[
:company_address
],
job
[
:company_description
]).
id
job_id
=
get_job
(
job_code
,
job
[
:title
],
job
[
:salary
],
job
[
:description
],
job
[
:requirement
],
job
[
:level
],
job
[
:post_date
],
job
[
:expiration_date
],
company_id
).
id
CityJob
.
find_or_create_by!
(
job_id:
job_id
,
city_id:
city_id
)
job
[
:company_id
]
=
get_company
(
company_code
,
job
[
:company_name
],
job
[
:company_address
],
job
[
:company_description
]).
id
saved_job
=
save_job
(
job
)
CityJob
.
find_or_create_by!
(
job_id:
saved_job
.
id
,
city_id:
city_id
)
job
[
:industries
].
each
do
|
job_industry
|
job_industry
=
job_industry
.
strip
industry_id
=
get_industry
(
job_industry
).
id
IndustryJob
.
find_or_create_by!
(
industry_id:
industry_id
,
job_id:
job_
id
)
IndustryJob
.
find_or_create_by!
(
industry_id:
industry_id
,
job_id
:
saved_job
.
id
)
end
end
end
...
...
@@ -67,19 +67,12 @@ class CrawlData
City
.
find_or_create_by
(
name:
name
,
region:
"Việt Nam"
)
end
def
get_job
(
code
=
nil
,
title
,
salary
,
description
,
requirement
,
level
,
post_date
,
expiration_date
,
company_id
)
attrs
=
expiration_date
.
nil?
?
{
title:
job_title
,
company_id:
company_id
}
:
{
code:
code
}
def
save_job
(
job_attrs
)
attrs
=
job_attrs
[
:expiration_date
].
nil?
?
{
title:
job_attrs
[:
title
],
company_id:
job_attrs
[
:company_id
]}
:
{
code:
job_attrs
[
:code
]}
job
=
Job
.
find_or_initialize_by
attrs
job
.
update_attributes
(
job_attrs
.
except
(
:workplace
,
:industries
,
:company_name
,
:company_address
,
:company_description
))
job
.
update
(
code:
code
,
title:
title
,
salary:
salary
,
post_date:
post_date
,
description:
description
,
requirement:
requirement
,
expiration_date:
expiration_date
,
level:
level
,
company_id:
company_id
)
job
end
end
app/services/job_html.rb
View file @
54e0368f
...
...
@@ -4,17 +4,18 @@ class JobHtml
end
def
parse_job
get_job_info
get_job_detail
job_info
=
get_job_info
job_detail
=
get_job_detail
{
title:
get_title
,
salary:
get_
job_info
[
:salary
],
level:
get_
job_info
[
:level
],
salary:
job_info
[
:salary
],
level:
job_info
[
:level
],
post_date:
get_post_date
,
description:
get_
job_detail
[
:description
],
requirement:
get_
job_detail
[
:requirement
],
expiration_date:
get_
job_info
[
:expiration_date
],
workplace:
get_
job_info
[
:workplace
],
industries:
get_
job_info
[
:industries
],
description:
job_detail
[
:description
],
requirement:
job_detail
[
:requirement
],
expiration_date:
job_info
[
:expiration_date
],
workplace:
job_info
[
:workplace
],
industries:
job_info
[
:industries
],
company_name:
get_company_name
,
company_address:
get_company_address
,
company_description:
get_company_description
}
...
...
@@ -50,7 +51,7 @@ class JobHtml
end
end
return
job_info
job_info
end
def
get_job_detail
...
...
@@ -66,7 +67,7 @@ class JobHtml
end
end
return
job_detail
job_detail
end
def
get_company_name
...
...
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