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
Mai Hoang Thai Ha
VenJob
Commits
a36e20ca
Commit
a36e20ca
authored
Aug 09, 2021
by
Mai Hoang Thai Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add includes to action index of job controller
parent
0e3f626d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
11 deletions
+19
-11
app/controllers/jobs_controller.rb
+2
-2
app/controllers/top_controller.rb
+1
-1
app/models/city.rb
+1
-2
app/models/industry.rb
+5
-1
app/views/jobs/index.html.slim
+4
-4
app/views/top/index.html.slim
+6
-1
No files found.
app/controllers/jobs_controller.rb
View file @
a36e20ca
...
...
@@ -3,7 +3,7 @@ class JobsController < ApplicationController
if
job_params
.
present?
search
else
@jobs
=
Job
.
page
(
params
[
:page
]).
per
(
20
)
@jobs
=
Job
.
includes
(
:company
).
page
(
params
[
:page
]).
per
(
20
)
end
end
...
...
@@ -17,7 +17,7 @@ class JobsController < ApplicationController
if
job_params
.
key?
(
:model
)
&&
job_params
.
key?
(
:slug
)
# search by model
model
=
params
[
:model
].
classify
.
constantize
@target
=
model
.
find_by
(
slug:
job_params
[
:slug
])
@jobs
=
@target
.
jobs
.
page
(
params
[
:page
]).
per
(
20
)
@jobs
=
@target
.
jobs
.
includes
(
:company
).
page
(
params
[
:page
]).
per
(
20
)
elsif
job_params
.
key?
(
:search
)
# search by keywords
wildcard_search
=
"%
#{
job_params
[
:search
]
}
%"
@jobs
=
Job
.
where
(
'name ILIKE ? OR postal_code LIKE ?'
,
wildcard_search
,
wildcard_search
)
...
...
app/controllers/top_controller.rb
View file @
a36e20ca
...
...
@@ -3,6 +3,6 @@ class TopController < ApplicationController
@total_job
=
Job
.
count
@latest_jobs
=
Job
.
latest
@top_cities
=
City
.
top_jobs
.
take
(
City
::
TOP_JOB_COUNT
)
@top_industries
=
Industry
.
job_quantity_by_industry
.
take
(
Industry
::
TOP_JOB_COUNT
)
@top_industries
=
Industry
.
top_jobs
.
take
(
Industry
::
TOP_JOB_COUNT
)
end
end
app/models/city.rb
View file @
a36e20ca
...
...
@@ -13,8 +13,7 @@ class City < ApplicationRecord
def
self
.
job_quantity_by_region
regions
.
each_with_object
({})
do
|
(
name
,
_
),
hash
|
hash
[
name
.
to_sym
]
=
send
(
name
).
joins
(
:jobs
).
group
(
:name
,
:slug
)
.
order
(
'COUNT(jobs.id) DESC'
).
count
hash
[
name
.
to_sym
]
=
send
(
name
).
joins
(
:jobs
).
group
(
:name
,
:slug
).
count
end
end
end
app/models/industry.rb
View file @
a36e20ca
...
...
@@ -5,7 +5,11 @@ class Industry < ApplicationRecord
validates
:slug
,
presence:
true
,
uniqueness:
{
case_sensitive:
true
}
def
self
.
job_quantity_by_industry
def
self
.
top_jobs
joins
(
:jobs
).
group
(
:name
,
:slug
).
order
(
'COUNT(jobs.id) DESC'
).
count
end
def
self
.
job_quantity_by_industry
joins
(
:jobs
).
group
(
:name
,
:slug
).
count
end
end
app/views/jobs/index.html.slim
View file @
a36e20ca
...
...
@@ -20,10 +20,10 @@
=
link_to
job
.
company
.
name
,
'#'
,
class:
'job-company text-decoration-none text-secondary'
p
.job-salary.text-success
|
Salary:
#{
job
.
salary
}
ul
.list-unstyled
-
job
.
cities
.
each
do
|
city
|
li
=
city
.
name
/
ul.list-unstyled
/
- job.cities.each do |city|
/
li
/
= city.name
.job-desc
=
truncate
(
simple_format
(
job
.
description
),
escape:
false
,
length:
250
)
hr
.my-4
...
...
app/views/top/index.html.slim
View file @
a36e20ca
-
provide
(
:title
,
'Home page'
)
/ search box
=
render
'shared/search'
.container
.row.text-center
.col
h2
.my-4
|
Total:
#{
pluralize
(
@total_job
,
"job"
)
}
=
render
'shared/search'
/ latest job
.latest-job.mb-5
.container.mb-5
...
...
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