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
1
Merge Requests
1
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
Tô Ngọc Ánh
VeNJob
Commits
28ad2bf6
Commit
28ad2bf6
authored
Jul 31, 2020
by
Tô Ngọc Ánh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor code
parent
03ee3000
Pipeline
#754
canceled with stages
in 0 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
8 deletions
+14
-8
app/models/industry.rb
+4
-1
app/models/location.rb
+4
-1
app/views/home/index.html.erb
+3
-3
app/views/layouts/application.html.erb
+2
-2
app/views/shared/_header.html.erb
+0
-0
lib/tasks/import_data.rake
+1
-1
No files found.
app/models/industry.rb
View file @
28ad2bf6
class
Industry
<
ApplicationRecord
scope
:top_industries
,
->
(
number
)
{
joins
(
:jobs
).
group
(
:industry_id
).
order
(
Arel
.
sql
(
'count(jobs.id) DESC'
)).
take
(
number
)
}
scope
:top_industries
,
->
(
number
)
{
joins
(
:jobs
)
.
group
(
:industry_id
)
.
order
(
Arel
.
sql
(
'count(jobs.id) DESC'
))
.
take
(
number
)
}
has_and_belongs_to_many
:jobs
end
app/models/location.rb
View file @
28ad2bf6
class
Location
<
ApplicationRecord
scope
:top_locations
,
->
(
number
)
{
joins
(
:jobs
).
group
(
:location_id
).
order
(
Arel
.
sql
(
'count(jobs.id) DESC'
)).
take
(
number
)
}
scope
:top_locations
,
->
(
number
)
{
joins
(
:jobs
)
.
group
(
:location_id
)
.
order
(
Arel
.
sql
(
'count(jobs.id) DESC'
))
.
take
(
number
)
}
CITY_VIETNAM_NUMBER
=
70
...
...
app/views/home/index.html.erb
View file @
28ad2bf6
...
...
@@ -11,19 +11,19 @@
<div
class=
'row'
>
<%=
render
partial:
'home/job'
,
collection:
@jobs
%>
</div>
<a
href=
'#'
>
See more...
</a>
<a
href=
'#'
>
All jobs
</a>
</div>
<div
id=
'top-city'
class=
'my-4 text-center'
>
<h1>
Top Cities
</h1>
<div
class=
'row'
>
<%=
render
partial:
'home/city'
,
collection:
@top_cities
,
as: :location
%>
</div>
<a
href=
'#'
>
See more...
</a>
<a
href=
'#'
>
All Cities
</a>
</div>
<div
id=
'top-industry'
class=
'my-4 text-center'
>
<h1>
Top Industries
</h1>
<div
class=
'row'
>
<%=
render
partial:
'home/industry'
,
collection:
@top_industries
,
as: :industry
%>
</div>
<a
href=
'#'
>
See more...
</a>
<a
href=
'#'
>
All Industries
</a>
</div>
app/views/layouts/application.html.erb
View file @
28ad2bf6
...
...
@@ -9,8 +9,8 @@
<%=
javascript_include_tag
'application'
,
'data-turbolinks-track'
:
'reload'
%>
</head>
<body
class=
"container"
>
<%=
render
'shared/
navba
r'
%>
<body
class=
'container'
>
<%=
render
'shared/
heade
r'
%>
<%=
yield
%>
<%=
render
'shared/footer'
%>
</body>
...
...
app/views/shared/_
navba
r.html.erb
→
app/views/shared/_
heade
r.html.erb
View file @
28ad2bf6
File moved
lib/tasks/import_data.rake
View file @
28ad2bf6
...
...
@@ -3,7 +3,7 @@ require './lib/common/csv'
require
'./lib/common/crawler'
namespace
:import_data
do
logger
||
=
Logger
.
new
(
'./log/import_data.log'
)
logger
=
Logger
.
new
(
'./log/import_data.log'
)
desc
'crawl industries locations jobs'
task
:crawler
,
%i[page_number link]
=>
[
:environment
]
do
|
_
,
args
|
...
...
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