Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venjob_nth
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
Ngô Trung Hưng
venjob_nth
Commits
44da0847
Commit
44da0847
authored
Sep 11, 2020
by
Ngô Trung Hưng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix method search in admin_controller
parent
4eff9b54
Pipeline
#1100
canceled with stages
in 0 seconds
Changes
10
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
35 additions
and
21 deletions
+35
-21
app/controllers/admin/admin_controller.rb
+11
-13
app/controllers/users_controller.rb
+1
-1
app/views/admin/admin/_box_filter.html.erb
+2
-2
app/views/admin/admin/_box_result_applied.html.erb
+0
-0
app/views/admin/admin/_card_candidate.html.erb
+0
-0
app/views/admin/admin/index.html.erb
+0
-0
app/views/apply_job/_block_info_job.html.erb
+1
-1
app/views/users/personal_page.html.erb
+1
-0
config/routes.rb
+3
-4
lib/tasks/admin.rake
+16
-0
No files found.
app/controllers/admin_controller.rb
→
app/controllers/admin
/admin
_controller.rb
View file @
44da0847
# frozen_string_literal: true
# Admin controller
class
AdminController
<
ApplicationController
class
Admin
::
AdminController
<
ApplicationController
before_action
:authenticate_admin!
,
only:
%s(index search export_csv)
before_action
:load_data_dropdown
include
InitApply
...
...
@@ -14,17 +15,16 @@ class AdminController < ApplicationController
end
def
index
Rails
.
cache
.
delete
(
:search_result
)
@applied
=
AppliedJob
.
all_result
.
page
(
params
[
:page
]).
per
(
6
)
@applied
=
AppliedJob
.
includes
(
:job
).
all_result
.
page
(
params
[
:page
]).
per
(
6
)
@apply
=
apply
end
def
search
return
redirect_to
applies_index_path
if
params
[
:apply
].
blank?
Rails
.
cache
.
delete
(
:search_result
)
Rails
.
cache
.
fetch
(
:search_result
,
expires_in:
1
.
day
)
{
result_for
(
params
[
:apply
])
}
@applied
=
result_for
(
params
[
:apply
]).
page
(
params
[
:page
]).
per
(
6
)
return
export_csv
(
result_for
(
params
[
:apply
]))
if
params
[
:export_csv
].
present?
@applied
=
result_for
(
params
[
:apply
]).
includes
(
:job
).
page
(
params
[
:page
]).
per
(
6
)
@city_id
=
params
[
:apply
][
:city_id
]
@industry_id
=
params
[
:apply
][
:industry_id
]
@params_date
=
params
[
:apply
]
...
...
@@ -32,13 +32,6 @@ class AdminController < ApplicationController
render
:index
end
def
export_csv
csv
=
ExportCsv
.
new
(
Rails
.
cache
.
fetch
(
:search_result
)
||
AppliedJob
.
all_result
,
AppliedJob
::
CSV_ATTR
)
respond_to
do
|
format
|
format
.
csv
{
send_data
csv
.
perform
,
filename:
"
#{
Time
.
now
}
applied.csv"
}
end
end
def
load_data_dropdown
@industries
=
Industry
.
order
(
name: :asc
)
@cities
=
City
.
select
(
:id
,
:name
)
...
...
@@ -49,4 +42,9 @@ class AdminController < ApplicationController
def
result_for
(
params
)
Searches
.
new
(
params
).
search
end
def
export_csv
(
result
)
csv
=
ExportCsv
.
new
(
result
,
AppliedJob
::
CSV_ATTR
)
send_data
csv
.
perform
,
filename:
"
#{
Time
.
now
}
applied.csv"
end
end
app/controllers/users_controller.rb
View file @
44da0847
...
...
@@ -12,7 +12,7 @@ class UsersController < ApplicationController
def
personal_page
@user
=
User
.
find_by_id
params
[
:user_id
]
return
render
'error/page_not_found'
if
@user
.
blank?
@jobs
=
@user
.
applied_jobs
.
includes
(
:job
).
order
(
created_at: :desc
)
@jobs
=
@user
.
applied_jobs
.
includes
(
:job
).
order
(
created_at: :desc
)
.
page
(
params
[
:page
]).
per
(
20
)
end
def
set_lang
...
...
app/views/admin/_box_filter.html.erb
→
app/views/admin/
admin/
_box_filter.html.erb
View file @
44da0847
...
...
@@ -44,7 +44,7 @@
</div>
<div
class=
"col-lg-4 col-md-4"
>
<div
class=
"admin_box_search__btn"
>
<%=
f
.
submit
t
(
'admin.filter'
),
class:
'btn btn-success btn-admin-search'
%>
<%=
f
.
submit
t
(
'admin.filter'
),
class:
'btn btn-success btn-admin-search'
,
data:
{
disable_with:
false
}
%>
</div>
</div>
<div
class=
"col-lg-4 col-md-4"
>
...
...
@@ -54,7 +54,7 @@
</div>
<div
class=
"col-lg-4 col-md-4"
>
<div
class=
"admin_box_search__btn"
>
<%=
link_to
t
(
'admin.dl'
),
export_csv_path
(
format: :csv
),
class:
'btn btn-primary btn-admin-search btn-export_csv'
%>
<%=
f
.
submit
t
(
'admin.dl'
),
name:
'export_csv'
,
class:
'btn btn-primary btn-admin-search btn-export_csv'
,
data:
{
disable_with:
false
}
%>
</div>
</div>
</div>
...
...
app/views/admin/_box_result_applied.html.erb
→
app/views/admin/
admin/
_box_result_applied.html.erb
View file @
44da0847
File moved
app/views/admin/_card_candidate.html.erb
→
app/views/admin/
admin/
_card_candidate.html.erb
View file @
44da0847
File moved
app/views/admin/index.html.erb
→
app/views/admin/
admin/
index.html.erb
View file @
44da0847
File moved
app/views/apply_job/_block_info_job.html.erb
View file @
44da0847
...
...
@@ -16,7 +16,7 @@
<div
class=
"col-lg-4"
>
<div
class=
"loc"
>
<h5
class=
"box_info_location"
><i
class=
"fas fa-map-marker-alt"
></i>
<%=
data
.
job
.
cities
.
map
(
&
:name
).
join
(
' | '
)
%>
<%=
data
.
job
.
cities
.
pluck
(
:name
).
join
(
' | '
)
%>
</h5>
</div>
</div>
...
...
app/views/users/personal_page.html.erb
View file @
44da0847
...
...
@@ -39,4 +39,5 @@
<%
end
%>
</div>
</div>
<%=
render
'shared/paginate'
,
data:
@jobs
,
as: :data
%>
<%=
render
'shared/scroll_top'
%>
config/routes.rb
View file @
44da0847
...
...
@@ -7,10 +7,9 @@ Rails.application.routes.draw do
devise_for
:admins
,
path:
'admin'
,
path_names:
{
sign_in:
'login'
,
sign_out:
'logout'
}
root
'home#index'
get
'admin/export_csv'
,
to:
'admin#export_csv'
,
as: :export_csv
get
'admin/search'
,
to:
'admin#search'
,
as: :applies
get
'admin/applies'
,
to:
'admin#index'
,
as: :applies_index
get
'admin'
,
to:
'admin#routing'
,
as: :admin
get
'admin/search'
,
to:
'admin/admin#search'
,
as: :applies
get
'admin/applies'
,
to:
'admin/admin#index'
,
as: :applies_index
get
'admin'
,
to:
'admin/admin#routing'
,
as: :admin
get
'info/user/:user_id'
,
to:
'users#personal_page'
,
as: :personal_page
...
...
lib/tasks/admin.rake
View file @
44da0847
...
...
@@ -8,4 +8,20 @@ namespace :admin do
ad
.
password_confirmation
=
'11111111'
end
end
task
dumb_data: :environment
do
logger
=
Logger
.
new
(
Rails
.
root
.
join
(
'log'
,
'dumb_data.log'
))
user
=
User
.
find
1
3000
.
times
do
|
i
|
user
.
applied_jobs
.
create!
do
|
obj
|
obj
.
user_id
=
user
.
id
obj
.
job_id
=
i
obj
.
name
=
user
.
name
obj
.
email
=
user
.
email
obj
.
cv
=
user
.
cv
end
rescue
StandardError
=>
e
logger
.
error
e
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