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
1
Merge Requests
1
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
Tô Ngọc Ánh
VeNJob
Commits
f57206c1
Commit
f57206c1
authored
Aug 04, 2020
by
Tô Ngọc Ánh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug index industry page, refactor code
parent
148f59aa
Pipeline
#783
canceled with stages
in 0 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
19 deletions
+16
-19
app/controllers/industries_controller.rb
+1
-1
app/controllers/locations_controller.rb
+2
-2
app/models/industry.rb
+2
-2
app/models/location.rb
+3
-3
app/views/home/index.html.erb
+2
-2
app/views/industries/_industry.html.erb
+1
-1
app/views/locations/_location.html.erb
+2
-3
app/views/locations/index.html.erb
+3
-5
No files found.
app/controllers/industries_controller.rb
View file @
f57206c1
class
IndustriesController
<
ApplicationController
class
IndustriesController
<
ApplicationController
def
index
def
index
@industries
=
Industry
.
all
@industries
=
Industry
.
with_count_job
end
end
end
end
app/controllers/locations_controller.rb
View file @
f57206c1
class
LocationsController
<
ApplicationController
class
LocationsController
<
ApplicationController
def
index
def
index
@vn_cities_lists
=
Location
.
vietnam
.
count_job
@vn_cities_lists
=
Location
.
vietnam
.
with_
count_job
@internal_cities_lists
=
Location
.
international
.
count_job
@internal_cities_lists
=
Location
.
international
.
with_
count_job
end
end
end
end
app/models/industry.rb
View file @
f57206c1
class
Industry
<
ApplicationRecord
class
Industry
<
ApplicationRecord
scope
:count_job
,
->
{
joins
(
:jobs
).
group
(
:industry_id
).
select
(
'industries.*, count(jobs.id) as job_count'
)
}
scope
:
with_
count_job
,
->
{
joins
(
:jobs
).
group
(
:industry_id
).
select
(
'industries.*, count(jobs.id) as job_count'
)
}
scope
:top_industries
,
->
(
number
)
{
count_job
.
order
(
Arel
.
sql
(
'count(jobs.id)
DESC'
)).
limit
(
number
)
}
scope
:top_industries
,
->
(
number
)
{
with_count_job
.
order
(
Arel
.
sql
(
'job_count
DESC'
)).
limit
(
number
)
}
has_and_belongs_to_many
:jobs
has_and_belongs_to_many
:jobs
end
end
app/models/location.rb
View file @
f57206c1
class
Location
<
ApplicationRecord
class
Location
<
ApplicationRecord
scope
:count_job
,
->
{
joins
(
:jobs
).
group
(
:location_id
).
select
(
'locations.*, count(jobs.id) as job_count'
)
}
scope
:
with_
count_job
,
->
{
joins
(
:jobs
).
group
(
:location_id
).
select
(
'locations.*, count(jobs.id) as job_count'
)
}
scope
:top_locations
,
->
(
number
)
{
count_job
.
order
(
Arel
.
sql
(
'job_count DESC'
)).
limit
(
number
)
}
scope
:top_locations
,
->
(
number
)
{
with_
count_job
.
order
(
Arel
.
sql
(
'job_count DESC'
)).
limit
(
number
)
}
scope
:international
,
->
{
where
(
oversea:
true
)
}
scope
:international
,
->
{
where
(
oversea:
true
)
}
scope
:vietnam
,
->
{
where
(
oversea:
false
)
}
scope
:vietnam
,
->
{
where
(
oversea:
false
)
}
CITY_VIETNAM_NUMBER
=
70
CITY_VIETNAM_NUMBER
=
70
has_many
:locations_jobs
has_many
:locations_jobs
...
...
app/views/home/index.html.erb
View file @
f57206c1
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<h1>
Top Cities
</h1>
<h1>
Top Cities
</h1>
<hr>
<hr>
<div
class=
'row'
>
<div
class=
'row'
>
<%=
render
partial:
'locations/
city'
,
collection:
@top_cities
,
as: :location
%>
<%=
render
partial:
'locations/
location'
,
collection:
@top_cities
%>
</div>
</div>
<%=
link_to
'All Citites'
,
cities_path
%>
<%=
link_to
'All Citites'
,
cities_path
%>
</div>
</div>
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
<h1>
Top Industries
</h1>
<h1>
Top Industries
</h1>
<hr>
<hr>
<div
class=
'row'
>
<div
class=
'row'
>
<%=
render
partial:
'industries/industry'
,
collection:
@top_industries
,
as: :industry
%>
<%=
render
partial:
'industries/industry'
,
collection:
@top_industries
%>
</div>
</div>
<%=
link_to
'All Industries'
,
industries_path
%>
<%=
link_to
'All Industries'
,
industries_path
%>
</div>
</div>
app/views/industries/_industry.html.erb
View file @
f57206c1
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
class=
'card'
>
<div
class=
'card'
>
<%=
link_to
'#'
,
class:
'card-body text-decoration-none'
do
%>
<%=
link_to
'#'
,
class:
'card-body text-decoration-none'
do
%>
<h5
class=
'card-title font-weight-bold'
>
<%=
industry
.
name
%>
</h5>
<h5
class=
'card-title font-weight-bold'
>
<%=
industry
.
name
%>
</h5>
<p
class=
'card-text'
>
<%=
industry
.
job_count
%>
Jobs
</p>
<p
class=
'card-text'
>
<%=
pluralize
(
industry
.
job_count
,
'Job'
)
%>
</p>
<%
end
%>
<%
end
%>
</div>
</div>
</div>
</div>
app/views/locations/_
city
.html.erb
→
app/views/locations/_
location
.html.erb
View file @
f57206c1
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
class=
'card'
>
<div
class=
'card'
>
<%=
link_to
'#'
,
class:
'card-body text-decoration-none'
do
%>
<%=
link_to
'#'
,
class:
'card-body text-decoration-none'
do
%>
<h5
class=
'card-title font-weight-bold'
>
<%=
location
.
city
%>
</h5>
<h5
class=
'card-title font-weight-bold'
>
<%=
location
.
city
%>
</h5>
<p
class=
'card-text'
>
<%=
location
.
job_count
%>
Jobs
</p>
<p
class=
'card-text'
>
<%=
pluralize
(
location
.
job_count
,
'Job'
)
%>
</p>
<%
end
%>
<%
end
%>
</div>
</div>
</div>
</div>
\ No newline at end of file
app/views/locations/index.html.erb
View file @
f57206c1
<div
class=
'list my-3 text-center'
>
<div
class=
'list my-3 text-center'
>
<h2>
Area List
</h2>
<h2>
Area List
</h2>
<hr>
<hr>
<ul
class=
'list-group list-group-horizontal'
>
<ul
class=
'list-group list-group-horizontal
justify-content-center
'
>
<li
class=
'list-group-item'
>
<li
class=
'list-group-item'
>
<a
href=
'#vietnam'
>
Việt Nam
</a>
<a
href=
'#vietnam'
>
Việt Nam
</a>
<span
class=
'badge badge-primary badge-pill'
>
<%=
@vn_cities_lists
.
length
%>
</span>
</li>
</li>
<li
class=
'list-group-item'
>
<li
class=
'list-group-item'
>
<a
href=
'#international'
>
International
</a>
<a
href=
'#international'
>
International
</a>
<span
class=
'badge badge-primary badge-pill'
>
<%=
@internal_cities_lists
.
length
%>
</span>
</li>
</li>
</ul>
</ul>
</div>
</div>
...
@@ -16,13 +14,13 @@
...
@@ -16,13 +14,13 @@
<h2>
Vietnam
</h2>
<h2>
Vietnam
</h2>
<hr>
<hr>
<div
class=
'row'
>
<div
class=
'row'
>
<%=
render
partial:
'locations/
city'
,
collection:
@vn_cities_lists
,
as: :location
%>
<%=
render
partial:
'locations/
location'
,
collection:
@vn_cities_lists
%>
</div>
</div>
</div>
</div>
<div
id=
'international'
class=
'text-center'
>
<div
id=
'international'
class=
'text-center'
>
<h2>
International
</h2>
<h2>
International
</h2>
<hr>
<hr>
<div
class=
"row"
>
<div
class=
"row"
>
<%=
render
partial:
'locations/
city'
,
collection:
@internal_cities_lists
,
as: :location
%>
<%=
render
partial:
'locations/
location'
,
collection:
@internal_cities_lists
%>
</div>
</div>
</div>
</div>
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