Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjob_thanhnd
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
3
Merge Requests
3
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
thanhnd
venjob_thanhnd
Commits
2f8c9a9a
Commit
2f8c9a9a
authored
Apr 08, 2020
by
thanhnd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix review 20200408 1
parent
704c20ee
Pipeline
#559
canceled with stages
in 0 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
13 deletions
+15
-13
app/assets/stylesheets/cities.scss
+0
-3
app/assets/stylesheets/industries.scss
+0
-3
app/controllers/industries_controller.rb
+1
-1
app/models/city.rb
+10
-4
app/models/industry.rb
+3
-1
app/views/industries/index.html.erb
+1
-1
No files found.
app/assets/stylesheets/cities.scss
deleted
100644 → 0
View file @
704c20ee
// Place all the styles related to the cities controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
app/assets/stylesheets/industries.scss
deleted
100644 → 0
View file @
704c20ee
// Place all the styles related to the industries controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
app/controllers/industries_controller.rb
View file @
2f8c9a9a
class
IndustriesController
<
ApplicationController
def
index
@
all_industry
=
Industry
.
all
_industries_by_job
@
top_industry
=
Industry
.
top
_industries_by_job
end
end
app/models/city.rb
View file @
2f8c9a9a
...
...
@@ -3,20 +3,26 @@ class City < ApplicationRecord
has_many
:jobs
validates_presence_of
:city_name
TOP_CITY_BY_JOB
=
9
def
self
.
top_cities_by_job
City
.
joins
(
:jobs
).
select
(
'cities.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.city_id'
).
order
(
:job_count
).
reverse_order
.
first
(
9
)
#City.joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order.first(TOP_CITY_BY_JOB)
joins
(
:jobs
).
select
(
'cities.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.city_id'
).
order
(
:job_count
).
reverse_order
.
first
(
TOP_CITY_BY_JOB
)
end
def
self
.
top_cities_by_job_nn
City
.
joins
(
:jobs
).
where
(
"cities.area_id = 2"
).
select
(
'cities.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.city_id'
).
order
(
:job_count
).
reverse_order
.
first
(
9
)
#City.joins(:jobs).where("cities.area_id = 2").select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order.first(TOP_CITY_BY_JOB)
joins
(
:jobs
).
where
(
"cities.area_id = 2"
).
select
(
'cities.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.city_id'
).
order
(
:job_count
).
reverse_order
.
first
(
TOP_CITY_BY_JOB
)
end
def
self
.
all_cities_by_job
City
.
joins
(
:jobs
).
select
(
'cities.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.city_id'
).
order
(
:job_count
).
reverse_order
#City.joins(:jobs).select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order
joins
(
:jobs
).
select
(
'cities.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.city_id'
).
order
(
:job_count
).
reverse_order
end
def
self
.
all_cities_by_job_nn
City
.
joins
(
:jobs
).
where
(
"cities.area_id = 2"
).
select
(
'cities.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.city_id'
).
order
(
:job_count
).
reverse_order
#City.joins(:jobs).where("cities.area_id = 2").select('cities.*, COUNT(jobs.id) as job_count').group('jobs.city_id').order(:job_count).reverse_order
joins
(
:jobs
).
where
(
"cities.area_id = 2"
).
select
(
'cities.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.city_id'
).
order
(
:job_count
).
reverse_order
end
end
app/models/industry.rb
View file @
2f8c9a9a
...
...
@@ -3,8 +3,10 @@ class Industry < ApplicationRecord
has_many
:jobs
validates_presence_of
:industry_name
TOP_INDUSTRY_BY_JOB
=
9
def
self
.
top_industries_by_job
Industry
.
joins
(
:jobs
).
select
(
'industries.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.industry_id'
).
order
(
:job_count
).
last
(
9
)
Industry
.
joins
(
:jobs
).
select
(
'industries.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.industry_id'
).
order
(
:job_count
).
last
(
TOP_INDUSTRY_BY_JOB
)
end
def
self
.
all_industries_by_job
...
...
app/views/industries/index.html.erb
View file @
2f8c9a9a
...
...
@@ -11,7 +11,7 @@
<div
id=
"industry_list"
class=
"container p-5 my-2 bg-secondary text-white"
>
<font
color=
"red"
><b><label
>
Industry List:
</label></b></font>
<%
@
all
_industry
.
each
do
|
industry
|
%>
<%
@
top
_industry
.
each
do
|
industry
|
%>
<ul>
<li>
<%=
industry
.
industry_name
%>
<br
/>
Total jobs in this industry:
<%=
industry
.
job_count
%>
</li>
</ul>
...
...
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