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
bdda7391
Commit
bdda7391
authored
Aug 10, 2021
by
Mai Hoang Thai Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix method sort_by_date
parent
9d46edb2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
+5
-5
app/controllers/jobs_controller.rb
+2
-2
app/controllers/top_controller.rb
+1
-1
app/models/job.rb
+2
-2
No files found.
app/controllers/jobs_controller.rb
View file @
bdda7391
...
@@ -3,7 +3,7 @@ class JobsController < ApplicationController
...
@@ -3,7 +3,7 @@ class JobsController < ApplicationController
if
job_params
.
present?
if
job_params
.
present?
search
search
else
else
@jobs
=
Job
.
sort_by_date
.
page
(
params
[
:page
]).
per
(
Job
::
JOB_PER_PAGE
)
@jobs
=
Job
.
sort_by_date
(
page:
params
[
:page
],
per_page:
Job
::
JOB_PER_PAGE
)
end
end
end
end
...
@@ -17,7 +17,7 @@ class JobsController < ApplicationController
...
@@ -17,7 +17,7 @@ class JobsController < ApplicationController
if
job_params
.
key?
(
:model
)
&&
job_params
.
key?
(
:slug
)
# search by model
if
job_params
.
key?
(
:model
)
&&
job_params
.
key?
(
:slug
)
# search by model
model
=
params
[
:model
].
classify
.
constantize
model
=
params
[
:model
].
classify
.
constantize
@target
=
model
.
find_by
(
slug:
job_params
[
:slug
])
@target
=
model
.
find_by
(
slug:
job_params
[
:slug
])
@jobs
=
@target
.
jobs
.
sort_by_date
.
page
(
params
[
:page
]).
per
(
Job
::
JOB_PER_PAGE
)
@jobs
=
@target
.
jobs
.
sort_by_date
(
page:
params
[
:page
],
per_page:
Job
::
JOB_PER_PAGE
)
end
end
end
end
...
...
app/controllers/top_controller.rb
View file @
bdda7391
class
TopController
<
ApplicationController
class
TopController
<
ApplicationController
def
index
def
index
@total_job
=
Job
.
count
@total_job
=
Job
.
count
@latest_jobs
=
Job
.
sort_by_date
.
limit
(
Job
::
LATEST_JOBS_LIMIT
)
@latest_jobs
=
Job
.
sort_by_date
(
per_page:
Job
::
LATEST_JOBS_LIMIT
)
@top_cities
=
City
.
top_jobs
@top_cities
=
City
.
top_jobs
@top_industries
=
Industry
.
top_jobs
@top_industries
=
Industry
.
top_jobs
end
end
...
...
app/models/job.rb
View file @
bdda7391
...
@@ -9,7 +9,7 @@ class Job < ApplicationRecord
...
@@ -9,7 +9,7 @@ class Job < ApplicationRecord
has_many
:favorite_jobs
,
dependent: :destroy
has_many
:favorite_jobs
,
dependent: :destroy
has_many
:history_job
,
dependent: :destroy
has_many
:history_job
,
dependent: :destroy
def
self
.
sort_by_date
def
self
.
sort_by_date
(
page:
1
,
per_page:
limit
)
joins
(
:cities
).
includes
(
:cities
,
:cities_jobs
,
:company
).
order
(
created_at: :desc
)
joins
(
:cities
).
includes
(
:cities
,
:cities_jobs
,
:company
).
order
(
created_at: :desc
)
.
page
(
page
).
per
(
per_page
)
end
end
end
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