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
0f84c9fd
Commit
0f84c9fd
authored
Sep 01, 2021
by
Mai Hoang Thai Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add index for favorite and history
parent
a59c56fc
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
38 deletions
+49
-38
app/controllers/favorite_jobs_controller.rb
+2
-1
app/controllers/history_jobs_controller.rb
+2
-1
app/models/history_job.rb
+1
-1
app/models/job.rb
+3
-3
app/views/favorite_jobs/index.html.slim
+7
-12
app/views/history_jobs/index.html.slim
+32
-20
app/views/layouts/_header.html.slim
+2
-0
No files found.
app/controllers/favorite_jobs_controller.rb
View file @
0f84c9fd
...
...
@@ -3,7 +3,8 @@ class FavoriteJobsController < ApplicationController
before_action
:load_job
,
only:
%i[create destroy]
def
index
@apply_jobs
=
Job
.
apply_jobs_of
(
current_user
.
id
).
sort_by_date
(
page:
params
[
:page
],
per_page:
Job
::
JOB_PER_PAGE
)
@jobs
=
Job
.
jobs_of
(
'favorite_jobs'
,
current_user
.
id
)
.
page
(
params
[
:page
]).
per
(
Job
::
JOB_PER_PAGE
)
end
def
create
...
...
app/controllers/history_jobs_controller.rb
View file @
0f84c9fd
...
...
@@ -4,6 +4,7 @@ class HistoryJobsController < ApplicationController
def
index
# job_id_list = current_user.history_jobs.map(&:job_id)
# @jobs = Job.includes(:cities, :cities_jobs, :company).references(:cities).find(job_id_list)
@history_jobs
=
Job
.
history_jobs_of
(
current_user
.
id
)
@history_jobs
=
Job
.
jobs_of
(
'history_jobs'
,
current_user
.
id
)
.
page
(
params
[
:page
]).
per
(
Job
::
JOB_PER_PAGE
)
end
end
app/models/history_job.rb
View file @
0f84c9fd
...
...
@@ -8,6 +8,6 @@ class HistoryJob < ApplicationRecord
def
history_count
history_list
=
user
.
history_jobs
.
order
(
updated_at: :desc
)
history_list
.
last
.
destroy
if
history_list
.
count
>
20
history_list
.
last
.
destroy
if
history_list
.
count
>
=
20
end
end
app/models/job.rb
View file @
0f84c9fd
class
Job
<
ApplicationRecord
scope
:
history_jobs_of
,
->
(
user_id
)
do
joins
(
:history_jobs
)
.
where
(
"
history_jobs
.user_id =
#{
user_id
}
"
)
scope
:
jobs_of
,
->
(
model
,
user_id
)
do
joins
(
model
.
to_sym
)
.
where
(
"
#{
model
.
to_sym
}
.user_id =
#{
user_id
}
"
)
.
includes
(
:cities
,
:cities_jobs
,
:company
).
references
(
:cities
)
end
...
...
app/views/favorite_jobs/index.html.slim
View file @
0f84c9fd
-
provide
(
:title
,
'Job list page'
)
/ search box
=
render
'shared/search'
-
provide
(
:title
,
'favorite page'
)
.container
h1
.mt-5
=
@name
hr
.my-4
.no-padding.d-flex.align-items-center.flex-column
.page-info.p-2
=
page_entries_info
@
apply_
jobs
=
page_entries_info
@jobs
.page-info.p-2
=
paginate
@
apply_
jobs
=
paginate
@jobs
.container
.container
-
@
apply_
jobs
.
each
do
|
job
|
-
@jobs
.
each
do
|
job
|
/ job
.job-item
.job-head.d-flex.align-items-center.justify-content-between
...
...
@@ -32,6 +27,6 @@
hr
.my-4
.no-padding.d-flex.align-items-center.flex-column
.page-info.p-2
=
page_entries_info
@
apply_
jobs
=
page_entries_info
@jobs
.page-info.p-2
=
paginate
@apply_jobs
\ No newline at end of file
=
paginate
@jobs
\ No newline at end of file
app/views/history_jobs/index.html.slim
View file @
0f84c9fd
-
provide
(
:title
,
'favorite page'
)
.container
.my-5
-
@history_jobs
.
each
do
|
job
|
.job-item
.job-head.d-flex.align-items-center.justify-content-between
=
link_to
job
.
title
,
job
,
class:
'job-title fs-3 text-decoration-none text-reset'
-
if
user_signed_in?
&&
current_user
.
favorite?
(
job
)
=
render
'shared/unfavorite'
,
job_id:
job
.
id
-
else
=
render
'shared/favorite'
,
job_id:
job
.
id
.job-caption
=
link_to
job
.
company
.
name
,
'#'
,
class:
'job-company text-decoration-none text-secondary'
p
.job-salary.text-success
|
Salary:
#{
job
.
salary
}
ul
.list-unstyled
=
show_location
(
job
.
cities
)
.job-desc
=
truncate
(
simple_format
(
job
.
description
),
escape:
false
,
length:
250
)
hr
.my-4
\ No newline at end of file
.no-padding.d-flex.align-items-center.flex-column
.page-info.p-2
=
page_entries_info
@history_jobs
.page-info.p-2
=
paginate
@history_jobs
.container
.container
-
@history_jobs
.
each
do
|
job
|
/ job
.job-item
.job-head.d-flex.align-items-center.justify-content-between
=
link_to
job
.
title
,
job
,
class:
'job-title fs-3 text-decoration-none text-reset'
-
if
user_signed_in?
&&
current_user
.
favorite?
(
job
)
=
render
'shared/unfavorite'
,
job_id:
job
.
id
-
else
=
render
'shared/favorite'
,
job_id:
job
.
id
.job-caption
=
link_to
job
.
company
.
name
,
'#'
,
class:
'job-company text-decoration-none text-secondary'
p
.job-salary.text-success
|
Salary:
#{
job
.
salary
}
ul
.list-unstyled
=
show_location
(
job
.
cities
)
.job-desc
=
truncate
(
simple_format
(
job
.
description
),
escape:
false
,
length:
250
)
hr
.my-4
.no-padding.d-flex.align-items-center.flex-column
.page-info.p-2
=
page_entries_info
@history_jobs
.page-info.p-2
=
paginate
@history_jobs
\ No newline at end of file
app/views/layouts/_header.html.slim
View file @
0f84c9fd
...
...
@@ -8,6 +8,8 @@ header.navbar.navbar-fixed-top.navbar-inverse
li
=
link_to
"History"
,
history_jobs_path
li
=
link_to
"Favorite"
,
favorite_jobs_path
li
=
link_to
"Profile"
,
user_profile_path
li
=
link_to
"Log out"
,
destroy_user_session_path
,
method: :delete
...
...
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