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
Nguyen Hoang Mai Phuong
VeNJOB
Commits
56de9774
Commit
56de9774
authored
Aug 03, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix view ID4
parent
e25c9b9b
Pipeline
#1378
failed with stages
in 0 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
58 additions
and
32 deletions
+58
-32
app/assets/stylesheets/custom.scss
+15
-2
app/controllers/jobs_controller.rb
+5
-4
app/controllers/top_controller.rb
+4
-3
app/models/city.rb
+5
-4
app/models/industry.rb
+6
-4
app/models/job.rb
+2
-1
app/views/cities/show.html.slim
+3
-2
app/views/industries/show.html.slim
+2
-1
app/views/jobs/_search.html.slim
+3
-5
app/views/jobs/show.html.slim
+10
-3
app/views/top/home.html.slim
+2
-2
config/initializers/kaminari_config.rb
+1
-1
No files found.
app/assets/stylesheets/custom.scss
View file @
56de9774
...
...
@@ -42,4 +42,18 @@
.form
{
width
:
700px
}
\ No newline at end of file
}
.card-body
{
float
:
left
;
}
.favourite
{
float
:
right
;
.btn
{
height
:
100%
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
}
app/controllers/jobs_controller.rb
View file @
56de9774
...
...
@@ -2,10 +2,10 @@ class JobsController < ApplicationController
def
show
if
params
[
:city_slug
].
present?
@city
=
City
.
find_by
(
slug:
params
[
:city_slug
])
@jobs
=
@city
.
jobs
.
order
(
created_at: :desc
).
page
(
params
[
:page
]).
per
(
20
)
els
if
params
[
:industry_slug
].
present?
@jobs
=
@city
.
jobs
.
latest_jobs
.
page
(
params
[
:page
]
)
els
e
@industry
=
Industry
.
find_by
(
slug:
params
[
:industry_slug
])
@jobs
=
@industry
.
jobs
.
order
(
created_at: :desc
).
page
(
params
[
:page
]).
per
(
20
)
@jobs
=
@industry
.
jobs
.
latest_jobs
.
page
(
params
[
:page
])
end
end
end
end
\ No newline at end of file
app/controllers/top_controller.rb
View file @
56de9774
class
TopController
<
ApplicationController
def
home
@jobs
=
Job
.
latest_jobs
@jobs
=
Job
.
latest_jobs
.
limit
(
Job
::
LATEST_JOB_NUMBER
)
@cities
=
City
.
top_cities
@industries
=
Industry
.
top_industries
@total_job
=
Job
.
all
.
count
@total_job
=
Job
.
count
end
end
end
\ No newline at end of file
app/models/city.rb
View file @
56de9774
class
City
<
ApplicationRecord
extend
FriendlyId
friendly_id
:name
,
use:
%i[slugged finders]
belongs_to
:region
has_and_belongs_to_many
:jobs
has_and_belongs_to_many
:companies
LATEST_CITY_NUMBER
=
9
REGION_VN_ID
=
1
REGION_INTERNATIONAL_ID
=
2
scope
:top_cities
,
->
{
joins
(
:jobs
).
group
(
:name
).
order
(
'count_all DESC'
).
count
.
take
(
LATEST_CITY_NUMBER
)
}
scope
:cities_by_region
,
->
(
value
)
{
joins
(
:jobs
).
group
(
:name
).
having
(
'count_all >= ?'
,
1
).
where
(
'region_id = ?'
,
value
).
order
(
'count_all DESC'
).
count
}
extend
FriendlyId
friendly_id
:name
,
use:
%i[slugged finders]
scope
:top_cities
,
->
{
joins
(
:jobs
).
group
(
:name
,
:slug
).
order
(
'count_all DESC'
).
count
.
take
(
LATEST_CITY_NUMBER
)
}
scope
:cities_by_region
,
->
(
value
)
{
joins
(
:jobs
).
group
(
:name
,
:slug
).
having
(
'count_all >= ?'
,
1
).
where
(
'region_id = ?'
,
value
).
order
(
'count_all DESC'
).
count
}
def
normalize_friendly_id
(
string
)
string
.
to_s
.
to_slug
.
normalize
(
transliterations: :vietnamese
).
to_s
end
...
...
app/models/industry.rb
View file @
56de9774
class
Industry
<
ApplicationRecord
has_and_belongs_to_many
:jobs
LATEST_INDUSTRY_NUMBER
=
9
scope
:top_industries
,
->
{
joins
(
:jobs
).
group
(
:name
).
order
(
'count_all DESC'
).
count
.
take
(
LATEST_INDUSTRY_NUMBER
)
}
scope
:industry_list
,
->
{
joins
(
:jobs
).
group
(
:name
).
having
(
'count_all >= ?'
,
1
).
order
(
'count_all DESC'
).
count
}
extend
FriendlyId
friendly_id
:name
,
use:
%i[slugged finders]
has_and_belongs_to_many
:jobs
LATEST_INDUSTRY_NUMBER
=
9
scope
:top_industries
,
->
{
joins
(
:jobs
).
group
(
:name
,
:slug
).
order
(
'count_all DESC'
).
count
.
take
(
LATEST_INDUSTRY_NUMBER
)
}
scope
:industry_list
,
->
{
joins
(
:jobs
).
group
(
:name
,
:slug
).
having
(
'count_all >= ?'
,
1
).
order
(
'count_all DESC'
).
count
}
def
normalize_friendly_id
(
string
)
string
.
to_s
.
to_slug
.
normalize
(
transliterations: :vietnamese
).
to_s
end
...
...
app/models/job.rb
View file @
56de9774
...
...
@@ -6,5 +6,5 @@ class Job < ApplicationRecord
has_and_belongs_to_many
:industries
has_and_belongs_to_many
:cities
LATEST_JOB_NUMBER
=
5
scope
:latest_jobs
,
->
{
includes
(
:cities
,
:
company
).
order
(
'created_at DESC'
).
limit
(
LATEST_JOB_NUMBER
)
}
scope
:latest_jobs
,
->
{
includes
(
:cities
,
:
industries
,
:company
).
order
(
'created_at DESC'
)
}
end
\ No newline at end of file
app/views/cities/show.html.slim
View file @
56de9774
...
...
@@ -14,7 +14,7 @@
.row.my-3.text-center.fs-5
-
@cities_vietnam
.
each
do
|
name
,
amount
|
.col-3.p-2.border.mb-1.fw-normal.bg-white
=
link_to
name
,
city_slug_path
(
City
.
find_by
(
name:
name
)
)
=
link_to
name
[
0
],
city_slug_path
(
name
[
1
]
)
p
.mb-1
=
amount
#international
...
...
@@ -23,6 +23,6 @@
.row.my-3.text-center.fs-5
-
@cities_international
.
each
do
|
name
,
amount
|
.col-3.p-2.border.mb-1.fw-normal.bg-white
=
link_to
name
,
city_slug_path
(
City
.
find_by
(
name:
name
)
)
=
link_to
name
[
0
],
city_slug_path
(
name
[
1
]
)
p
.mb-1
=
amount
\ No newline at end of file
app/views/industries/show.html.slim
View file @
56de9774
...
...
@@ -6,6 +6,6 @@
.row.my-3.text-center.fs-5
-
@industry_list
.
each
do
|
name
,
amount
|
.col-3.p-2.border.mb-1.fw-normal.bg-white
=
link_to
name
,
industry_slug_path
(
Industry
.
friendly
.
find_by
(
name:
name
)
)
=
link_to
name
[
0
],
industry_slug_path
(
name
[
1
]
)
p
.mb-1
=
amount
\ No newline at end of file
app/views/jobs/_search.html.slim
View file @
56de9774
.search.p-3.offset-md-2
=
form_with
(
url:
'/
search
'
,
method:
'get'
,
local:
true
)
do
=
form_with
(
url:
'/
jobs
'
,
method:
'get'
,
local:
true
)
do
=
text_field_tag
:search
,
params
[
:search
],
placeholder:
"Search"
,
class:
"form"
=
submit_tag
"Search"
,
name:
nil
,
class:
'btn-primary'
=
submit_tag
"Search"
,
name:
nil
,
class:
'btn-primary'
\ No newline at end of file
app/views/jobs/show.html.slim
View file @
56de9774
...
...
@@ -2,12 +2,16 @@
=
render
'search'
.container
h5
.fw-normal
|
Total:
h5
.fw-normal
|
Result for:
h6
.offset-md-4
=
paginate
@jobs
,
window:
1
.job-list
-
@jobs
.
each
do
|
job
|
.
card.my-3
.card-body.text-dark
.
row.bg-white
.c
ol-10.p-3.border.c
ard-body.text-dark
h5
.mb-1
=
link_to
job
.
title
,
"#"
p
.mb-1
...
...
@@ -21,7 +25,9 @@
=
link_to
job
.
cities
.
map
(
&
:name
).
uniq
.
join
(
' | '
),
"#"
p
.mb-1
=
truncate
(
job
.
overview
,
length:
250
)
.col-sm-2.p-3.border.favourite
=
link_to
"Farourite"
,
"#"
,
class:
"btn btn-outline-primary"
h6
.offset-md-4.px-5
=
page_entries_info
@jobs
h6
.offset-md-4
=
paginate
@jobs
,
window:
1
=
paginate
@jobs
,
window:
1
\ No newline at end of file
app/views/top/home.html.slim
View file @
56de9774
...
...
@@ -26,7 +26,7 @@ h3.p-2
.row.my-3.text-center.fs-5
-
@cities
.
each
do
|
name
,
amount
|
.col-4.p-2.border.mb-1.fw-normal.bg-white
=
link_to
name
,
city_slug_path
(
City
.
find_by
(
name:
name
))
=
link_to
name
[
0
],
city_slug_path
(
name
[
1
])
p
.mb-1
=
amount
.d-flex.flex-row-reverse.
...
...
@@ -36,7 +36,7 @@ h3.p-2
.row.my-3.text-center.fs-5
-
@industries
.
each
do
|
name
,
amount
|
.col-4.p-2.border.mb-1.fw-normal.bg-white
=
link_to
name
,
industry_slug_path
(
Industry
.
find_by
(
name:
name
))
=
link_to
name
[
0
],
industry_slug_path
(
name
[
1
])
p
.mb-1
=
amount
.d-flex.flex-row-reverse
...
...
config/initializers/kaminari_config.rb
View file @
56de9774
# frozen_string_literal: true
Kaminari
.
configure
do
|
config
|
# config.default_per_page = 25
config
.
default_per_page
=
20
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
...
...
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