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
473812a9
Commit
473812a9
authored
Aug 07, 2020
by
Ngô Trung Hưng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduce amount query
parent
45098883
Pipeline
#845
failed with stages
in 0 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
8 additions
and
6 deletions
+8
-6
app/controllers/home_controller.rb
+1
-1
app/controllers/job_controller.rb
+1
-1
app/models/city.rb
+2
-1
app/models/industry.rb
+2
-1
app/views/home/_box_nine_city.html.erb
+1
-1
app/views/home/_box_nine_industries.html.erb
+1
-1
No files found.
app/controllers/home_controller.rb
View file @
473812a9
...
@@ -6,7 +6,7 @@ class HomeController < ApplicationController
...
@@ -6,7 +6,7 @@ class HomeController < ApplicationController
@industries
=
Industry
.
order
(
name: :asc
).
all
@industries
=
Industry
.
order
(
name: :asc
).
all
@job_count
=
Job
.
count
@job_count
=
Job
.
count
@cities
=
City
.
all_cities
@cities
=
City
.
all_cities
@lasted_jobs
=
Job
.
order
(
created_at: :desc
).
limit
(
Job
::
NUMBER_LASTED_JOB
)
@lasted_jobs
=
Job
.
order
(
created_at: :desc
).
includes
(
:company
,
:cities
).
limit
(
Job
::
NUMBER_LASTED_JOB
)
@top_cities
=
City
.
top_cities
(
9
)
@top_cities
=
City
.
top_cities
(
9
)
@top_industries
=
Industry
.
top_industries
(
9
)
@top_industries
=
Industry
.
top_industries
(
9
)
end
end
...
...
app/controllers/job_controller.rb
View file @
473812a9
...
@@ -19,7 +19,7 @@ class JobController < ApplicationController
...
@@ -19,7 +19,7 @@ class JobController < ApplicationController
def
render_result
(
obj
)
def
render_result
(
obj
)
@keyword
=
obj
.
name
@keyword
=
obj
.
name
@data
=
obj
.
jobs
.
page
(
params
[
:page
])
@data
=
obj
.
jobs
.
includes
(
:company
,
:cities
).
page
(
params
[
:page
])
render
'result_data'
render
'result_data'
end
end
end
end
app/models/city.rb
View file @
473812a9
...
@@ -12,7 +12,8 @@ class City < ApplicationRecord
...
@@ -12,7 +12,8 @@ class City < ApplicationRecord
scope
:all_cities
,
->
{
select
:id
,
:name
}
scope
:all_cities
,
->
{
select
:id
,
:name
}
scope
:top_cities
,
->
(
number
)
do
joins
(
:jobs
)
scope
:top_cities
,
->
(
number
)
do
joins
(
:jobs
)
.
group
(
:city_id
)
.
group
(
:city_id
)
.
order
(
Arel
.
sql
(
'count(jobs.id) DESC'
))
.
select
(
"cities.*, count(jobs.id) as job_count"
)
.
order
(
Arel
.
sql
(
'job_count DESC'
))
.
take
(
number
)
.
take
(
number
)
end
end
...
...
app/models/industry.rb
View file @
473812a9
...
@@ -7,7 +7,8 @@ class Industry < ApplicationRecord
...
@@ -7,7 +7,8 @@ class Industry < ApplicationRecord
has_many
:jobs
,
through: :industry_jobs
has_many
:jobs
,
through: :industry_jobs
scope
:top_industries
,
->
(
number
)
do
joins
(
:jobs
)
scope
:top_industries
,
->
(
number
)
do
joins
(
:jobs
)
.
group
(
:industry_id
)
.
group
(
:industry_id
)
.
order
(
Arel
.
sql
(
'count(jobs.id) DESC'
))
.
select
(
'industries.*, count(jobs.id) as job_count'
)
.
order
(
Arel
.
sql
(
'job_count DESC'
))
.
take
(
number
)
.
take
(
number
)
end
end
...
...
app/views/home/_box_nine_city.html.erb
View file @
473812a9
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<%=
link_to
city
.
name
,
jobs_path
(
model:
'city'
,
slug:
city
.
slug
),
class:
'link_ct'
%>
<%=
link_to
city
.
name
,
jobs_path
(
model:
'city'
,
slug:
city
.
slug
),
class:
'link_ct'
%>
</div>
</div>
<div
class=
"ct_jobs_count"
>
<div
class=
"ct_jobs_count"
>
<%=
link_to
"
#{
city
.
job
s
.
count
}
công việc"
,
jobs_path
(
model:
'city'
,
slug:
city
.
slug
),
class:
'link_ct'
%>
<%=
link_to
"
#{
city
.
job
_
count
}
công việc"
,
jobs_path
(
model:
'city'
,
slug:
city
.
slug
),
class:
'link_ct'
%>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
app/views/home/_box_nine_industries.html.erb
View file @
473812a9
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<%=
link_to
industry
.
name
,
jobs_path
(
model:
'industry'
,
slug:
industry
.
slug
),
class:
'link_ct'
%>
<%=
link_to
industry
.
name
,
jobs_path
(
model:
'industry'
,
slug:
industry
.
slug
),
class:
'link_ct'
%>
</div>
</div>
<div
class=
"ct_jobs_count"
>
<div
class=
"ct_jobs_count"
>
<%=
link_to
"
#{
industry
.
job
s
.
count
}
công việc"
,
jobs_path
(
model:
'industry'
,
slug:
industry
.
slug
),
class:
'link_ct'
%>
<%=
link_to
"
#{
industry
.
job
_
count
}
công việc"
,
jobs_path
(
model:
'industry'
,
slug:
industry
.
slug
),
class:
'link_ct'
%>
</div>
</div>
</div>
</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