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
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
14 additions
and
16 deletions
+14
-16
app/controllers/industries_controller.rb
+1
-1
app/controllers/locations_controller.rb
+2
-2
app/models/industry.rb
+2
-2
app/models/location.rb
+2
-2
app/views/home/index.html.erb
+2
-2
app/views/industries/_industry.html.erb
+1
-1
app/views/locations/_location.html.erb
+1
-1
app/views/locations/index.html.erb
+3
-5
No files found.
app/controllers/industries_controller.rb
View file @
f57206c1
class
IndustriesController
<
ApplicationController
def
index
@industries
=
Industry
.
all
@industries
=
Industry
.
with_count_job
end
end
app/controllers/locations_controller.rb
View file @
f57206c1
class
LocationsController
<
ApplicationController
def
index
@vn_cities_lists
=
Location
.
vietnam
.
count_job
@internal_cities_lists
=
Location
.
international
.
count_job
@vn_cities_lists
=
Location
.
vietnam
.
with_
count_job
@internal_cities_lists
=
Location
.
international
.
with_
count_job
end
end
app/models/industry.rb
View file @
f57206c1
class
Industry
<
ApplicationRecord
scope
: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
:
with_
count_job
,
->
{
joins
(
:jobs
).
group
(
:industry_id
).
select
(
'industries.*, count(jobs.id) as job_count'
)
}
scope
:top_industries
,
->
(
number
)
{
with_count_job
.
order
(
Arel
.
sql
(
'job_count
DESC'
)).
limit
(
number
)
}
has_and_belongs_to_many
:jobs
end
app/models/location.rb
View file @
f57206c1
class
Location
<
ApplicationRecord
scope
: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
:
with_
count_job
,
->
{
joins
(
:jobs
).
group
(
:location_id
).
select
(
'locations.*, count(jobs.id) as job_count'
)
}
scope
:top_locations
,
->
(
number
)
{
with_
count_job
.
order
(
Arel
.
sql
(
'job_count DESC'
)).
limit
(
number
)
}
scope
:international
,
->
{
where
(
oversea:
true
)
}
scope
:vietnam
,
->
{
where
(
oversea:
false
)
}
...
...
app/views/home/index.html.erb
View file @
f57206c1
...
...
@@ -17,7 +17,7 @@
<h1>
Top Cities
</h1>
<hr>
<div
class=
'row'
>
<%=
render
partial:
'locations/
city'
,
collection:
@top_cities
,
as: :location
%>
<%=
render
partial:
'locations/
location'
,
collection:
@top_cities
%>
</div>
<%=
link_to
'All Citites'
,
cities_path
%>
</div>
...
...
@@ -25,7 +25,7 @@
<h1>
Top Industries
</h1>
<hr>
<div
class=
'row'
>
<%=
render
partial:
'industries/industry'
,
collection:
@top_industries
,
as: :industry
%>
<%=
render
partial:
'industries/industry'
,
collection:
@top_industries
%>
</div>
<%=
link_to
'All Industries'
,
industries_path
%>
</div>
app/views/industries/_industry.html.erb
View file @
f57206c1
...
...
@@ -2,7 +2,7 @@
<div
class=
'card'
>
<%=
link_to
'#'
,
class:
'card-body text-decoration-none'
do
%>
<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
%>
</div>
</div>
app/views/locations/_
city
.html.erb
→
app/views/locations/_
location
.html.erb
View file @
f57206c1
...
...
@@ -2,7 +2,7 @@
<div
class=
'card'
>
<%=
link_to
'#'
,
class:
'card-body text-decoration-none'
do
%>
<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
%>
</div>
</div>
app/views/locations/index.html.erb
View file @
f57206c1
<div
class=
'list my-3 text-center'
>
<h2>
Area List
</h2>
<hr>
<ul
class=
'list-group list-group-horizontal'
>
<ul
class=
'list-group list-group-horizontal
justify-content-center
'
>
<li
class=
'list-group-item'
>
<a
href=
'#vietnam'
>
Việt Nam
</a>
<span
class=
'badge badge-primary badge-pill'
>
<%=
@vn_cities_lists
.
length
%>
</span>
</li>
<li
class=
'list-group-item'
>
<a
href=
'#international'
>
International
</a>
<span
class=
'badge badge-primary badge-pill'
>
<%=
@internal_cities_lists
.
length
%>
</span>
</li>
</ul>
</div>
...
...
@@ -16,13 +14,13 @@
<h2>
Vietnam
</h2>
<hr>
<div
class=
'row'
>
<%=
render
partial:
'locations/
city'
,
collection:
@vn_cities_lists
,
as: :location
%>
<%=
render
partial:
'locations/
location'
,
collection:
@vn_cities_lists
%>
</div>
</div>
<div
id=
'international'
class=
'text-center'
>
<h2>
International
</h2>
<hr>
<div
class=
"row"
>
<%=
render
partial:
'locations/
city'
,
collection:
@internal_cities_lists
,
as: :location
%>
<%=
render
partial:
'locations/
location'
,
collection:
@internal_cities_lists
%>
</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