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
...
@@ -3,7 +3,8 @@ class FavoriteJobsController < ApplicationController
before_action
:load_job
,
only:
%i[create destroy]
before_action
:load_job
,
only:
%i[create destroy]
def
index
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
end
def
create
def
create
...
...
app/controllers/history_jobs_controller.rb
View file @
0f84c9fd
...
@@ -4,6 +4,7 @@ class HistoryJobsController < ApplicationController
...
@@ -4,6 +4,7 @@ class HistoryJobsController < ApplicationController
def
index
def
index
# job_id_list = current_user.history_jobs.map(&:job_id)
# job_id_list = current_user.history_jobs.map(&:job_id)
# @jobs = Job.includes(:cities, :cities_jobs, :company).references(:cities).find(job_id_list)
# @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
end
end
app/models/history_job.rb
View file @
0f84c9fd
...
@@ -8,6 +8,6 @@ class HistoryJob < ApplicationRecord
...
@@ -8,6 +8,6 @@ class HistoryJob < ApplicationRecord
def
history_count
def
history_count
history_list
=
user
.
history_jobs
.
order
(
updated_at: :desc
)
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
end
end
app/models/job.rb
View file @
0f84c9fd
class
Job
<
ApplicationRecord
class
Job
<
ApplicationRecord
scope
:
history_jobs_of
,
->
(
user_id
)
do
scope
:
jobs_of
,
->
(
model
,
user_id
)
do
joins
(
:history_jobs
)
joins
(
model
.
to_sym
)
.
where
(
"
history_jobs
.user_id =
#{
user_id
}
"
)
.
where
(
"
#{
model
.
to_sym
}
.user_id =
#{
user_id
}
"
)
.
includes
(
:cities
,
:cities_jobs
,
:company
).
references
(
:cities
)
.
includes
(
:cities
,
:cities_jobs
,
:company
).
references
(
:cities
)
end
end
...
...
app/views/favorite_jobs/index.html.slim
View file @
0f84c9fd
-
provide
(
:title
,
'Job list page'
)
-
provide
(
:title
,
'favorite page'
)
/ search box
=
render
'shared/search'
.container
.container
h1
.mt-5
=
@name
hr
.my-4
.no-padding.d-flex.align-items-center.flex-column
.no-padding.d-flex.align-items-center.flex-column
.page-info.p-2
.page-info.p-2
=
page_entries_info
@
apply_
jobs
=
page_entries_info
@jobs
.page-info.p-2
.page-info.p-2
=
paginate
@
apply_
jobs
=
paginate
@jobs
.container
.container
.container
.container
-
@
apply_
jobs
.
each
do
|
job
|
-
@jobs
.
each
do
|
job
|
/ job
/ job
.job-item
.job-item
.job-head.d-flex.align-items-center.justify-content-between
.job-head.d-flex.align-items-center.justify-content-between
...
@@ -32,6 +27,6 @@
...
@@ -32,6 +27,6 @@
hr
.my-4
hr
.my-4
.no-padding.d-flex.align-items-center.flex-column
.no-padding.d-flex.align-items-center.flex-column
.page-info.p-2
.page-info.p-2
=
page_entries_info
@
apply_
jobs
=
page_entries_info
@jobs
.page-info.p-2
.page-info.p-2
=
paginate
@apply_jobs
=
paginate
@jobs
\ No newline at end of file
\ No newline at end of file
app/views/history_jobs/index.html.slim
View file @
0f84c9fd
-
provide
(
:title
,
'favorite page'
)
.container
.container
.my-5
.no-padding.d-flex.align-items-center.flex-column
-
@history_jobs
.
each
do
|
job
|
.page-info.p-2
.job-item
=
page_entries_info
@history_jobs
.job-head.d-flex.align-items-center.justify-content-between
.page-info.p-2
=
link_to
job
.
title
,
job
,
class:
'job-title fs-3 text-decoration-none text-reset'
=
paginate
@history_jobs
-
if
user_signed_in?
&&
current_user
.
favorite?
(
job
)
.container
=
render
'shared/unfavorite'
,
job_id:
job
.
id
.container
-
else
-
@history_jobs
.
each
do
|
job
|
=
render
'shared/favorite'
,
job_id:
job
.
id
/ job
.job-caption
.job-item
=
link_to
job
.
company
.
name
,
'#'
,
class:
'job-company text-decoration-none text-secondary'
.job-head.d-flex.align-items-center.justify-content-between
p
.job-salary.text-success
=
link_to
job
.
title
,
job
,
class:
'job-title fs-3 text-decoration-none text-reset'
|
Salary:
#{
job
.
salary
}
-
if
user_signed_in?
&&
current_user
.
favorite?
(
job
)
ul
.list-unstyled
=
render
'shared/unfavorite'
,
job_id:
job
.
id
=
show_location
(
job
.
cities
)
-
else
.job-desc
=
render
'shared/favorite'
,
job_id:
job
.
id
=
truncate
(
simple_format
(
job
.
description
),
escape:
false
,
length:
250
)
.job-caption
hr
.my-4
=
link_to
job
.
company
.
name
,
'#'
,
class:
'job-company text-decoration-none text-secondary'
\ No newline at end of file
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
...
@@ -8,6 +8,8 @@ header.navbar.navbar-fixed-top.navbar-inverse
li
li
=
link_to
"History"
,
history_jobs_path
=
link_to
"History"
,
history_jobs_path
li
li
=
link_to
"Favorite"
,
favorite_jobs_path
li
=
link_to
"Profile"
,
user_profile_path
=
link_to
"Profile"
,
user_profile_path
li
li
=
link_to
"Log out"
,
destroy_user_session_path
,
method: :delete
=
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