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
Huỳnh Thiên Phước
venjob
Commits
79e6c572
Commit
79e6c572
authored
Jul 30, 2020
by
Huỳnh Thiên Phước
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix code Import CSV and show Industry, City, Job
parent
8d6e1469
Pipeline
#741
failed with stages
in 0 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
78 additions
and
20 deletions
+78
-20
app/assets/stylesheets/top_pages.scss
+12
-0
app/controllers/top_pages_controller.rb
+4
-3
app/models/city.rb
+1
-0
app/models/city_job.rb
+1
-0
app/views/layouts/_show_cities.html.erb
+16
-0
app/views/layouts/_show_industries.html.erb
+16
-0
app/views/layouts/_show_jobs.html.erb
+3
-3
app/views/top_pages/index.html.erb
+6
-0
lib/src/crawler.rb
+18
-13
lib/src/crontab.rb
+1
-1
No files found.
app/assets/stylesheets/top_pages.scss
View file @
79e6c572
...
...
@@ -44,4 +44,15 @@
position
:
absolute
;
top
:
20%
;
right
:
5%
;
}
.row-table
{
color
:
black
;
padding
:
50px
;
margin
:
30px
;
text-align
:
center
;
border
:
2px
solid
red
;
}
table
{
width
:
100%
;
}
\ No newline at end of file
app/controllers/top_pages_controller.rb
View file @
79e6c572
class
TopPagesController
<
ApplicationController
def
index
@total_jobs
=
Job
.
ids
@total_jobs
=
Job
.
all
@jobs
=
Job
.
limit
(
5
).
order
(
created_at: :desc
)
@companies
=
Company
.
all
@total_cities
=
CityJob
.
all
.
group
(
'city_id'
).
count
@jobs_of_cities
=
CityJob
.
limit
(
9
).
group
(
'city_id'
).
order
(
'Count(*) DESC'
).
count
@jobs_of_industries
=
IndustryJob
.
limit
(
9
).
group
(
'industry_id'
).
order
(
'Count(*) DESC'
).
count
@index
=
0
end
end
app/models/city.rb
View file @
79e6c572
class
City
<
ApplicationRecord
has_many
:city_jobs
has_many
:jobs
,
through: :city_jobs
end
app/models/city_job.rb
View file @
79e6c572
class
CityJob
<
ApplicationRecord
belongs_to
:city
belongs_to
:job
end
app/views/layouts/_show_cities.html.erb
0 → 100644
View file @
79e6c572
<%
@jobs_of_cities
.
each
do
|
city
,
count_job
|
%>
<%
@index
+=
1
%>
<%
if
@index
%
3
==
0
%>
<td
class=
"row-table"
>
<div
class=
"city-name"
><strong>
<%=
City
.
find
(
city
).
name
%>
</strong></div>
<div
class=
"count-job"
>
<%=
count_job
%>
</div>
</td>
</tr>
<%
else
%>
<td
class=
"row-table"
>
<div
class=
"city-name"
><strong>
<%=
City
.
find
(
city
).
name
%>
</strong></div>
<div
class=
"count-job"
>
<%=
count_job
%>
</div>
</td>
<%
end
%>
<%
end
%>
\ No newline at end of file
app/views/layouts/_show_industries.html.erb
0 → 100644
View file @
79e6c572
<%
@jobs_of_industries
.
each
do
|
industry
,
count_job
|
%>
<%
@index
+=
1
%>
<%
if
@index
%
3
==
0
%>
<td
class=
"row-table"
>
<div
class=
"industry-name"
><strong>
<%=
Industry
.
find
(
industry
).
name
%>
</strong></div>
<div
class=
"count-job"
>
<%=
count_job
%>
</div>
</td>
</tr>
<%
else
%>
<td
class=
"row-table"
>
<div
class=
"industry-name"
><strong>
<%=
Industry
.
find
(
industry
).
name
%>
</strong></div>
<div
class=
"count-job"
>
<%=
count_job
%>
</div>
</td>
<%
end
%>
<%
end
%>
\ No newline at end of file
app/views/layouts/_show_jobs.html.erb
View file @
79e6c572
...
...
@@ -4,13 +4,13 @@
<div
class=
"job-details"
>
<div
class=
"title"
><strong>
<%=
job
.
title
%>
</strong></div>
<div>
<%=
job
.
company_name
%>
</div>
<div
class=
"salary"
>
<i
class=
"fas fa-dollar-sign"
></i>
Lương:
<%=
job
.
salary
%>
</div>
<div>
<i
class=
"fas fa-map-marker"
></i>
<div
class=
"salary"
>
$
Lương:
<%=
job
.
salary
%>
</div>
<div>
▼
<%
job
.
cities
.
each
do
|
city
|
%>
<%=
city
.
name
%>
<%
end
%>
</div>
<button
type=
"button"
class=
"btn btn-primary"
id=
"button-follow"
>
<i
class=
"fas fa-heart"
></i>
Follow
</button>
<button
type=
"button"
class=
"btn btn-primary"
id=
"button-follow"
>
♥
Follow
</button>
</div>
</div>
<br>
...
...
app/views/top_pages/index.html.erb
View file @
79e6c572
...
...
@@ -6,6 +6,12 @@
</div>
<div
class=
"container"
>
<div
class=
"job-list"
>
<%=
render
'layouts/show_jobs'
%>
</div>
<div>
<div
class=
"city-banner"
>
City
</div>
</div>
<table
class=
"city-list"
>
<%=
render
'layouts/show_cities'
%>
</table>
<div
class=
"city-banner"
>
Industry
</div>
<table
class=
"industry-list"
>
<%=
render
'layouts/show_industries'
%>
</table>
</div>
lib/src/crawler.rb
View file @
79e6c572
...
...
@@ -158,25 +158,30 @@ class Crawler
company_id:
company_table
.
id
)
puts
job_table
.
id
end
next
if
company_table
.
nil?
find_job
=
Job
.
find_by
(
title:
title_job
,
company_id:
company_table
.
id
)
industry
=
row
[
"category"
]
industry_find
=
Industry
.
find_by
(
name:
industry
)
if
industry_find
.
nil?
industry_table
=
Industry
.
create!
(
name:
industry
)
industry_job_table
=
IndustryJob
.
create!
(
job_id:
job_table
.
id
,
industry_id:
industry_find
.
id
)
else
industry_job_table
=
IndustryJob
.
create!
(
job_id:
job_table
.
id
,
industry_id:
industry_find
.
id
)
end
if
industry_find
.
nil?
&&
find_job
.
present?
industry_table
=
Industry
.
create!
(
name:
industry
)
industry_job_table
=
IndustryJob
.
create!
(
job_id:
job_table
.
id
,
industry_id:
industry_find
.
id
)
else
unless
IndustryJob
.
exists?
(
job_id:
find_job
.
id
,
industry_id:
industry_find
.
id
)
industry_job_table
=
IndustryJob
.
create!
(
job_id:
job_table
.
id
,
industry_id:
industry_find
.
id
)
end
end
puts
job_table
.
id
,
title_job
,
industry
,
salary
location_data
=
row
[
"work place"
]
location
=
location_data
.
gsub
(
'["'
,
''
).
gsub
(
'"]'
,
''
)
location_find
=
City
.
find_by
(
name:
location
)
if
location_find
.
nil?
city_table
=
City
.
create!
(
name:
location
)
city_job_table
=
CityJob
.
create!
(
job_id:
job_table
.
id
,
city_id:
location_find
.
id
)
else
city_job_table
=
CityJob
.
create!
(
job_id:
job_table
.
id
,
city_id:
location_find
.
id
)
end
puts
"Location:
#{
location
}
"
if
location_find
.
nil?
city_table
=
City
.
create!
(
name:
location
)
city_job_table
=
CityJob
.
create!
(
job_id:
job_table
.
id
,
city_id:
location_find
.
id
)
else
unless
CityJob
.
exists?
(
job_id:
find_job
.
id
,
city_id:
location_find
.
id
)
city_job_table
=
CityJob
.
create!
(
job_id:
job_table
.
id
,
city_id:
location_find
.
id
)
end
end
rescue
StandardError
=>
e
@mylogger
.
error
"
#{
e
.
message
}
"
end
...
...
lib/src/crontab.rb
View file @
79e6c572
...
...
@@ -60,7 +60,7 @@ class Crontab
location_rel
.
each
do
|
loc
|
city_table
=
City
.
find_by
(
name:
loc
)
next
if
city_table
.
nil?
unless
CityJob
.
exists?
(
job_id:
find_job
.
id
,
city_id:
city_table
.
id
)
.
nil?
unless
CityJob
.
exists?
(
job_id:
find_job
.
id
,
city_id:
city_table
.
id
)
puts
"Created City:
#{
find_job
.
id
}
-
#{
city_table
.
id
}
.
#{
loc
}
"
city_jobs
=
CityJob
.
create!
(
job_id:
find_job
.
id
,
city_id:
city_table
.
id
)
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