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
Huỳnh Thiên Phước
venjob
Commits
c4f83312
Commit
c4f83312
authored
Aug 04, 2020
by
Huỳnh Thiên Phước
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change handle in controller to handle in model
parent
f6afc562
Pipeline
#796
failed with stages
in 0 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
7 deletions
+9
-7
app/controllers/cities_controller.rb
+2
-2
app/models/city.rb
+4
-3
lib/src/job_parser.rb
+3
-2
No files found.
app/controllers/cities_controller.rb
View file @
c4f83312
class
CitiesController
<
ApplicationController
class
CitiesController
<
ApplicationController
def
index
def
index
@cities_vietnam
=
City
.
all_city
.
where
(
'location = 1'
)
@cities_vietnam
=
City
.
all_city
.
vietnam
@cities_international
=
City
.
all_city
.
where
(
'location = 0'
)
@cities_international
=
City
.
all_city
.
international
end
end
end
end
app/models/city.rb
View file @
c4f83312
...
@@ -2,10 +2,11 @@ class City < ApplicationRecord
...
@@ -2,10 +2,11 @@ class City < ApplicationRecord
has_many
:city_jobs
has_many
:city_jobs
has_many
:jobs
,
through: :city_jobs
has_many
:jobs
,
through: :city_jobs
scope
:all_city
,
->
{
joins
(
:jobs
).
group
(
:city_id
).
order
(
'count(job_id) DESC'
)
}
scope
:vietnam
,
->
{
where
(
'location = 1'
)
}
scope
:international
,
->
{
where
(
'location = 0'
)
}
def
self
.
top_city
def
self
.
top_city
joins
(
:jobs
).
group
(
:city_id
).
order
(
'count(job_id) DESC'
).
limit
(
9
)
joins
(
:jobs
).
group
(
:city_id
).
order
(
'count(job_id) DESC'
).
limit
(
9
)
end
end
def
self
.
all_city
joins
(
:jobs
).
group
(
:city_id
).
order
(
'count(job_id) DESC'
)
end
end
end
lib/src/job_parser.rb
View file @
c4f83312
...
@@ -15,8 +15,9 @@ class JobParser
...
@@ -15,8 +15,9 @@ class JobParser
links
=
info
.
css
(
'div.caption a.company-name'
).
map
{
|
link
|
link
[
'href'
]
}
links
=
info
.
css
(
'div.caption a.company-name'
).
map
{
|
link
|
link
[
'href'
]
}
links
.
each
do
|
link
|
links
.
each
do
|
link
|
next
if
link
==
'javascript:void(0);'
next
if
link
==
'javascript:void(0);'
page
=
Nokogiri
::
HTML
(
URI
.
open
(
URI
.
escape
(
link
)))
name
=
page
.
search
(
'p.name'
)
&
.
text
page
=
Nokogiri
::
HTML
(
URI
.
open
(
URI
.
escape
(
link
)))
name
=
page
.
search
(
'p.name'
)
&
.
text
next
if
name
.
blank?
next
if
name
.
blank?
address
=
page
.
css
(
'div.content p'
).
children
[
1
]
&
.
text
address
=
page
.
css
(
'div.content p'
).
children
[
1
]
&
.
text
...
...
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