Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
ven-job
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
Trịnh Hoàng Phúc
ven-job
Commits
475139e9
Commit
475139e9
authored
May 18, 2020
by
Hoang Phuc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean code
parent
cb35c893
Pipeline
#631
failed with stages
in 0 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
39 deletions
+30
-39
app/controllers/history_controller.rb
+6
-7
app/controllers/users_controller.rb
+11
-13
app/services/rsolr_service.rb
+2
-9
db/schema.rb
+11
-10
No files found.
app/controllers/history_controller.rb
View file @
475139e9
class
HistoryController
<
ApplicationController
class
HistoryController
<
ApplicationController
def
index
def
index
if
cookies
[
:job_ids_history
].
nil?
return
redirect_to
jobs_path
if
cookies
[
:job_ids_history
].
blank?
redirect_to
"/jobs"
else
arr_job_ids
=
cookies
[
:job_ids_history
].
split
(
","
)
arr_job_ids
=
cookies
[
:job_ids_history
].
split
(
","
)
job_ids
=
cookies
[
:job_ids_history
].
split
(
","
)
job_ids
=
cookies
[
:job_ids_history
].
split
(
","
)
@jobs_history
=
Job
.
where
(
"id IN (?)"
,
job_ids
).
order
(
"id DESC"
)
@jobs_history
=
Job
.
where
(
"id IN (?)"
,
job_ids
).
order
(
"id DESC"
)
end
end
end
end
end
\ No newline at end of file
app/controllers/users_controller.rb
View file @
475139e9
class
UsersController
<
ApplicationController
class
UsersController
<
ApplicationController
def
info
def
info
unless
user_signed_in?
redirect_to
user_session_path
unless
user_signed_in?
redirect_to
"/users/sign_in"
end
end
end
def
apply_jobs
def
apply_jobs
unless
user_signed_in?
redirect_to
user_session_path
unless
user_signed_in?
redirect_to
"/users/sign_in"
else
@applied_jobs
=
Apply
.
where
(
"user_id =
#{
current_user
.
id
}
"
)
@applied_jobs
=
Apply
.
where
(
"user_id = ?"
,
current_user
.
id
)
end
end
end
def
favorite_jobs
def
favorite_jobs
unless
user_signed_in?
redirect_to
user_session_path
unless
user_signed_in?
redirect_to
"/users/sign_in"
else
@favorite_jobs
=
Favorite
.
where
(
"user_id =
#{
current_user
.
id
}
"
)
@favorite_jobs
=
Favorite
.
where
(
"user_id = ?"
,
current_user
.
id
)
end
end
end
def
apply_or_favorite_jobs
def
apply_or_favorite_jobs
unless
user_signed_in?
unless
user_signed_in?
payload
=
{
payload
=
{
...
@@ -40,6 +37,7 @@ class UsersController < ApplicationController
...
@@ -40,6 +37,7 @@ class UsersController < ApplicationController
end
end
end
end
end
end
def
remove_favorite_job
def
remove_favorite_job
unless
user_signed_in?
unless
user_signed_in?
payload
=
{
payload
=
{
...
...
app/services/rsolr_service.rb
View file @
475139e9
require
"rsolr"
require
"rsolr"
class
RsolrService
class
RsolrService
attr_accessor
:solr_job
,
:
solr_apply
,
:apply
,
:
job
attr_accessor
:solr_job
,
:job
def
initialize
def
initialize
@solr_job
=
RSolr
.
connect
:url
=>
"http://localhost:8983/solr/job"
@solr_job
=
RSolr
.
connect
:url
=>
"http://localhost:8983/solr/job"
@solr_apply
=
RSolr
.
connect
:url
=>
"http://localhost:8983/solr/apply"
@apply
=
nil
@job
=
nil
@job
=
nil
end
end
def
query_apply
(
query_params
,
page
)
apply
=
solr_apply
.
paginate
page
,
Settings
.
admin
.
limit
,
"select"
,
:params
=>
{
:q
=>
query_params
}
apply
[
"response"
][
"docs"
]
end
def
query_job
(
query_params
,
page
)
def
query_job
(
query_params
,
page
)
job
=
solr_job
.
paginate
page
,
Settings
.
search
.
limit
,
"select"
,
:params
=>
{
job
=
solr_job
.
paginate
page
,
Settings
.
search
.
limit
,
"select"
,
:params
=>
{
:q
=>
query_params
:q
=>
query_params
...
...
db/schema.rb
View file @
475139e9
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
ActiveRecord
::
Schema
.
define
(
version:
2020_05_18_023337
)
do
ActiveRecord
::
Schema
.
define
(
version:
2020_05_18_023337
)
do
create_table
"admins"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
,
force: :cascade
do
|
t
|
create_table
"admins"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
"
,
force: :cascade
do
|
t
|
t
.
string
"email"
,
default:
""
,
null:
false
t
.
string
"email"
,
default:
""
,
null:
false
t
.
string
"encrypted_password"
,
default:
""
,
null:
false
t
.
string
"encrypted_password"
,
default:
""
,
null:
false
t
.
string
"reset_password_token"
t
.
string
"reset_password_token"
...
@@ -24,7 +24,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
...
@@ -24,7 +24,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t
.
index
[
"reset_password_token"
],
name:
"index_admins_on_reset_password_token"
,
unique:
true
t
.
index
[
"reset_password_token"
],
name:
"index_admins_on_reset_password_token"
,
unique:
true
end
end
create_table
"applies"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
,
force: :cascade
do
|
t
|
create_table
"applies"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
"
,
force: :cascade
do
|
t
|
t
.
bigint
"user_id"
,
null:
false
t
.
bigint
"user_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
...
@@ -33,21 +33,21 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
...
@@ -33,21 +33,21 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t
.
index
[
"user_id"
],
name:
"index_applies_on_user_id"
t
.
index
[
"user_id"
],
name:
"index_applies_on_user_id"
end
end
create_table
"cities"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
,
force: :cascade
do
|
t
|
create_table
"cities"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
"
,
force: :cascade
do
|
t
|
t
.
string
"title"
t
.
string
"title"
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
boolean
"foreign"
,
default:
false
t
.
boolean
"foreign"
,
default:
false
end
end
create_table
"cities_jobs"
,
id:
false
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
,
force: :cascade
do
|
t
|
create_table
"cities_jobs"
,
id:
false
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
"
,
force: :cascade
do
|
t
|
t
.
bigint
"city_id"
,
null:
false
t
.
bigint
"city_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
index
[
"city_id"
,
"job_id"
],
name:
"index_cities_jobs_on_city_id_and_job_id"
t
.
index
[
"city_id"
,
"job_id"
],
name:
"index_cities_jobs_on_city_id_and_job_id"
t
.
index
[
"job_id"
,
"city_id"
],
name:
"index_cities_jobs_on_job_id_and_city_id"
t
.
index
[
"job_id"
,
"city_id"
],
name:
"index_cities_jobs_on_job_id_and_city_id"
end
end
create_table
"companies"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
,
force: :cascade
do
|
t
|
create_table
"companies"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
"
,
force: :cascade
do
|
t
|
t
.
string
"title"
t
.
string
"title"
t
.
string
"address"
t
.
string
"address"
t
.
string
"logo"
t
.
string
"logo"
...
@@ -56,7 +56,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
...
@@ -56,7 +56,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
end
end
create_table
"favorites"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
,
force: :cascade
do
|
t
|
create_table
"favorites"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
"
,
force: :cascade
do
|
t
|
t
.
bigint
"user_id"
,
null:
false
t
.
bigint
"user_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
...
@@ -65,20 +65,20 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
...
@@ -65,20 +65,20 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t
.
index
[
"user_id"
],
name:
"index_favorites_on_user_id"
t
.
index
[
"user_id"
],
name:
"index_favorites_on_user_id"
end
end
create_table
"industries"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
,
force: :cascade
do
|
t
|
create_table
"industries"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
"
,
force: :cascade
do
|
t
|
t
.
string
"title"
t
.
string
"title"
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
end
end
create_table
"industries_jobs"
,
id:
false
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
,
force: :cascade
do
|
t
|
create_table
"industries_jobs"
,
id:
false
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
"
,
force: :cascade
do
|
t
|
t
.
bigint
"industry_id"
,
null:
false
t
.
bigint
"industry_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
index
[
"industry_id"
,
"job_id"
],
name:
"index_industries_jobs_on_industry_id_and_job_id"
t
.
index
[
"industry_id"
,
"job_id"
],
name:
"index_industries_jobs_on_industry_id_and_job_id"
t
.
index
[
"job_id"
,
"industry_id"
],
name:
"index_industries_jobs_on_job_id_and_industry_id"
t
.
index
[
"job_id"
,
"industry_id"
],
name:
"index_industries_jobs_on_job_id_and_industry_id"
end
end
create_table
"jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
,
force: :cascade
do
|
t
|
create_table
"jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
"
,
force: :cascade
do
|
t
|
t
.
string
"title"
t
.
string
"title"
t
.
string
"updated_date_job"
t
.
string
"updated_date_job"
t
.
string
"level"
t
.
string
"level"
...
@@ -97,7 +97,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
...
@@ -97,7 +97,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t
.
index
[
"company_id"
],
name:
"index_jobs_on_company_id"
t
.
index
[
"company_id"
],
name:
"index_jobs_on_company_id"
end
end
create_table
"users"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
,
force: :cascade
do
|
t
|
create_table
"users"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
"
,
force: :cascade
do
|
t
|
t
.
string
"email"
,
default:
""
,
null:
false
t
.
string
"email"
,
default:
""
,
null:
false
t
.
string
"encrypted_password"
,
default:
""
,
null:
false
t
.
string
"encrypted_password"
,
default:
""
,
null:
false
t
.
string
"reset_password_token"
t
.
string
"reset_password_token"
...
@@ -110,6 +110,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
...
@@ -110,6 +110,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
string
"full_name"
t
.
string
"full_name"
t
.
string
"image"
t
.
string
"cv"
t
.
string
"cv"
t
.
string
"provider"
t
.
string
"provider"
t
.
string
"uid"
t
.
string
"uid"
...
...
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