Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjob_thanhnd
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
3
Merge Requests
3
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
thanhnd
venjob_thanhnd
Commits
a583fb3e
Commit
a583fb3e
authored
Feb 26, 2020
by
thanhnd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix review toppage 20200226 2
parent
d23eeafb
Pipeline
#482
failed with stages
in 0 seconds
Changes
6
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
15 deletions
+22
-15
app/controllers/top_page_controller.rb
+3
-3
app/models/city.rb
+1
-1
app/models/industry.rb
+1
-1
app/models/job.rb
+1
-1
app/views/top_page/index.html.erb
+2
-2
lib/tasks/crawler.rake
+14
-7
No files found.
app/controllers/top_page_controller.rb
View file @
a583fb3e
class
TopPageController
<
ApplicationController
def
index
@total_jobs
=
Job
.
count
@latest_jobs
=
Job
.
latest_
five_
job
@top_industries
=
Industry
.
top_
nine_industry
@top_cities
=
City
.
top_
nine_city
@latest_jobs
=
Job
.
latest_job
@top_industries
=
Industry
.
top_
industry_by_job
@top_cities
=
City
.
top_
city_by_job
end
end
...
...
app/models/city.rb
View file @
a583fb3e
...
...
@@ -2,5 +2,5 @@ class City < ApplicationRecord
belongs_to
:area
has_many
:jobs
validates_presence_of
:city_name
scope
:top_
nine_city
,
->
{
joins
(
:jobs
).
select
(
'cities.*, COUNT(jobs.id) as jobcount'
).
group
(
'jobs.city_id'
).
order
(
:job
count
).
last
(
9
)}
scope
:top_
city_by_job
,
->
{
joins
(
:jobs
).
select
(
'cities.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.city_id'
).
order
(
:job_
count
).
last
(
9
)}
end
app/models/industry.rb
View file @
a583fb3e
...
...
@@ -2,5 +2,5 @@ class Industry < ApplicationRecord
has_many
:industry_jobs
has_many
:jobs
validates_presence_of
:industry_name
scope
:top_
nine_industry
,
->
{
joins
(
:jobs
).
select
(
'industries.*, COUNT(jobs.id) as jobcount'
).
group
(
'jobs.industry_id'
).
order
(
:job
count
).
last
(
9
)}
scope
:top_
industry_by_job
,
->
{
joins
(
:jobs
).
select
(
'industries.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.industry_id'
).
order
(
:job_
count
).
last
(
9
)}
end
app/models/job.rb
View file @
a583fb3e
...
...
@@ -7,5 +7,5 @@ class Job < ApplicationRecord
belongs_to
:city
belongs_to
:company
validates_presence_of
:job_name
scope
:latest_
five_
job
,
->
{
order
(
:last_updated
).
first
(
5
)}
scope
:latest_job
,
->
{
order
(
:last_updated
).
first
(
5
)}
end
app/views/top_page/index.html.erb
View file @
a583fb3e
...
...
@@ -39,9 +39,9 @@
<div
id=
"topindustry"
class=
"container p-5 my-2 bg-secondary text-white"
>
<font
color=
"red"
><b><label
>
Top Industry:
</label></b></font>
<%
@top_industries
.
each
do
|
top_industy
|
%>
<%
@top_industries
.
each
do
|
top_indust
r
y
|
%>
<ul>
<li>
<%=
top_industy
.
industry_name
%>
</li>
<li>
<%=
top_indust
r
y
.
industry_name
%>
</li>
</ul>
<%
end
%>
</div>
...
...
lib/tasks/crawler.rake
View file @
a583fb3e
...
...
@@ -47,26 +47,33 @@ namespace :crawler do
#skip if field blank
next
if
industry
.
text
.
blank?
#insert data to City table:
city_name
=
location
.
text
.
gsub
(
","
,
""
)
city
=
City
.
find_or_create_by
(
area_id:
area
.
id
,
city_name:
city_name
,
city_description:
""
)
city
=
City
.
find_by
(
area_id:
area
.
id
,
city_name:
city_name
)
city
=
City
.
create
(
area_id:
area
.
id
,
city_name:
city_name
,
city_description:
""
)
unless
city
#insert data to Industry table
industry
=
Industry
.
find_or_create_by
(
industry_name:
industry
.
text
,
industry_description:
""
)
industry_row
=
Industry
.
find_by
(
industry_name:
industry
.
text
)
industry_row
=
Industry
.
create
(
industry_name:
industry
.
text
,
industry_description:
""
)
unless
industry_row
#insert data to Companies table
company
=
Company
.
find_or_create_by
(
company_name:
company_name
.
text
,
company_description:
company_intro
.
text
,
address:
address
.
text
)
company
=
Company
.
find_by
(
company_name:
company_name
.
text
)
company
=
Company
.
create
(
company_name:
company_name
.
text
,
company_description:
company_intro
.
text
,
address:
address
.
text
)
unless
company
#insert data to Jobs table
job_table
=
Job
.
find_or_create_by
(
area_id:
area
.
id
,
city_id:
city
.
id
,
industry_id:
industry
.
id
,
company_id:
company
.
id
,
job_name:
title
.
text
,
salary:
salary
.
text
,
deadline:
deadline
.
text
,
level:
level
.
text
,
experience:
experience
.
text
.
strip
,
last_updated:
updated_date
.
text
.
strip
,
description:
description
.
text
)
job_row
=
Job
.
find_by
(
area_id:
area
.
id
,
city_id:
city
.
id
,
industry_id:
industry_row
.
id
,
company_id:
company
.
id
,
job_name:
title
.
text
)
job_row
=
Job
.
create
(
area_id:
area
.
id
,
city_id:
city
.
id
,
industry_id:
industry_row
.
id
,
company_id:
company
.
id
,
job_name:
title
.
text
,
salary:
salary
.
text
,
deadline:
deadline
.
text
,
level:
level
.
text
,
experience:
experience
.
text
.
strip
,
last_updated:
updated_date
.
text
.
strip
,
description:
description
.
text
)
unless
job_row
#insert data to Industry_Jobs table
IndustryJob
.
find_or_create_by
(
industry_id:
industry
.
id
,
job_id:
job_table
.
id
)
unless
IndustryJob
.
exists?
(
industry_id:
industry_row
.
id
,
job_id:
job_row
.
id
)
IndustryJob
.
create
(
industry_id:
industry_row
.
id
,
job_id:
job_row
.
id
)
end
end
list_url
=
nextpage
[
0
][
"href"
]
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