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
f8e30777
Commit
f8e30777
authored
Apr 08, 2020
by
thanhnd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix review 20200408 2
parent
2f8c9a9a
Pipeline
#560
failed with stages
in 0 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
6 deletions
+2
-6
app/models/city.rb
+0
-4
app/models/industry.rb
+2
-2
No files found.
app/models/city.rb
View file @
f8e30777
...
@@ -6,22 +6,18 @@ class City < ApplicationRecord
...
@@ -6,22 +6,18 @@ class City < ApplicationRecord
TOP_CITY_BY_JOB
=
9
TOP_CITY_BY_JOB
=
9
def
self
.
top_cities_by_job
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(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
)
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
end
def
self
.
top_cities_by_job_nn
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(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
)
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
end
def
self
.
all_cities_by_job
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
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
end
def
self
.
all_cities_by_job_nn
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
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 @
f8e30777
...
@@ -6,10 +6,10 @@ class Industry < ApplicationRecord
...
@@ -6,10 +6,10 @@ class Industry < ApplicationRecord
TOP_INDUSTRY_BY_JOB
=
9
TOP_INDUSTRY_BY_JOB
=
9
def
self
.
top_industries_by_job
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
(
TOP_INDUSTRY_BY_JOB
)
joins
(
:jobs
).
select
(
'industries.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.industry_id'
).
order
(
:job_count
).
last
(
TOP_INDUSTRY_BY_JOB
)
end
end
def
self
.
all_industries_by_job
def
self
.
all_industries_by_job
Industry
.
joins
(
:jobs
).
select
(
'industries.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.industry_id'
).
order
(
:job_count
).
reverse_order
joins
(
:jobs
).
select
(
'industries.*, COUNT(jobs.id) as job_count'
).
group
(
'jobs.industry_id'
).
order
(
:job_count
).
reverse_order
end
end
end
end
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