Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjob_nth
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
Ngô Trung Hưng
venjob_nth
Commits
4b00c948
Commit
4b00c948
authored
Aug 03, 2020
by
Ngô Trung Hưng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use scope top hot
parent
5bc09eea
Pipeline
#765
canceled with stages
in 0 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
25 deletions
+16
-25
app/controllers/home_controller.rb
+2
-2
app/models/city.rb
+4
-8
app/models/industry.rb
+4
-9
app/views/home/_box_nine_city.html.erb
+3
-3
app/views/home/_box_nine_industries.html.erb
+3
-3
No files found.
app/controllers/home_controller.rb
View file @
4b00c948
...
...
@@ -7,7 +7,7 @@ class HomeController < ApplicationController
@job_count
=
Job
.
count
@cities
=
City
.
all_cities
@lasted_jobs
=
Job
.
order
(
created_at: :desc
).
limit
(
Job
::
NUMBER_LASTED_JOB
)
@top_cities
=
City
.
top_
hot
.
take
(
9
)
@top_industries
=
Industry
.
top_
hot
.
take
(
9
)
@top_cities
=
City
.
top_
cities
(
9
)
@top_industries
=
Industry
.
top_
industries
(
9
)
end
end
app/models/city.rb
View file @
4b00c948
...
...
@@ -5,13 +5,9 @@ class City < ApplicationRecord
has_many
:city_jobs
has_many
:jobs
,
through: :city_jobs
scope
:all_cities
,
->
{
select
:id
,
:name
}
def
self
.
top_hot
hash
=
{}
data_cities
=
City
.
all
data_cities
.
each
do
|
val
|
hash
[
val
.
name
]
=
val
.
jobs
.
count
end
hash
.
sort_by
{
|
k
,
v
|
v
}.
reverse
scope
:top_cities
,
->
(
number
)
do
joins
(
:jobs
)
.
group
(
:city_id
)
.
order
(
Arel
.
sql
(
'count(jobs.id) DESC'
))
.
take
(
number
)
end
end
app/models/industry.rb
View file @
4b00c948
...
...
@@ -4,14 +4,9 @@
class
Industry
<
ApplicationRecord
has_many
:industry_jobs
has_many
:jobs
,
through: :industry_jobs
def
self
.
top_hot
hash
=
{}
data_industries
=
Industry
.
all
data_industries
.
each
do
|
val
|
hash
[
val
.
name
]
=
val
.
jobs
.
count
end
hash
=
hash
.
select
{
|
k
,
v
|
v
.
positive?
}
hash
.
sort_by
{
|
k
,
v
|
v
}.
reverse
scope
:top_industries
,
->
(
number
)
do
joins
(
:jobs
)
.
group
(
:industry_id
)
.
order
(
Arel
.
sql
(
'count(jobs.id) DESC'
))
.
take
(
number
)
end
end
app/views/home/_box_nine_city.html.erb
View file @
4b00c948
...
...
@@ -4,14 +4,14 @@
<span>
Top thành phố
</span>
</div>
<div
class=
"row no-gutters"
>
<%
@top_cities
.
each
do
|
k
,
v
|
%>
<%
@top_cities
.
each
do
|
city
|
%>
<div
class=
"col-lg-4 col-md-4 col-sm-6 col-xs-12"
>
<div
class=
"box_info_city"
>
<div
class=
"ct_name"
>
<%=
link_to
k
,
'#'
,
class:
'link_ct'
%>
<%=
link_to
city
.
name
,
'#'
,
class:
'link_ct'
%>
</div>
<div
class=
"ct_jobs_count"
>
<%=
link_to
"
#{
v
}
công việc"
,
'#'
,
class:
'link_ct'
%>
<%=
link_to
"
#{
city
.
jobs
.
count
}
công việc"
,
'#'
,
class:
'link_ct'
%>
</div>
</div>
</div>
...
...
app/views/home/_box_nine_industries.html.erb
View file @
4b00c948
...
...
@@ -4,14 +4,14 @@
<span>
Top các nghành phổ biến
</span>
</div>
<div
class=
"row no-gutters"
>
<%
@top_industries
.
each
do
|
name
,
jobs_count
|
%>
<%
@top_industries
.
each
do
|
industry
|
%>
<div
class=
"col-lg-4 col-md-4 col-sm-6 col-xs-12"
>
<div
class=
"box_info_city"
>
<div
class=
"ct_name"
>
<%=
link_to
name
,
'#'
,
class:
'link_ct'
%>
<%=
link_to
industry
.
name
,
'#'
,
class:
'link_ct'
%>
</div>
<div
class=
"ct_jobs_count"
>
<%=
link_to
"
#{
jobs_
count
}
công việc"
,
'#'
,
class:
'link_ct'
%>
<%=
link_to
"
#{
industry
.
jobs
.
count
}
công việc"
,
'#'
,
class:
'link_ct'
%>
</div>
</div>
</div>
...
...
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