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
1
Merge Requests
1
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
Tô Ngọc Ánh
VeNJob
Commits
4552c30b
Commit
4552c30b
authored
Sep 10, 2020
by
Tô Ngọc Ánh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CSV download
parent
9a91355f
Pipeline
#1093
failed with stages
in 0 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
7 deletions
+40
-7
app/controllers/applied_jobs_controller.rb
+8
-2
app/models/applied_job.rb
+2
-0
app/services/export_csv_service.rb
+21
-0
app/services/search_applied_jobs_service.rb
+6
-2
app/views/users/_applied_job.html.erb
+1
-1
app/views/users/applied_jobs.html.erb
+2
-2
No files found.
app/controllers/applied_jobs_controller.rb
View file @
4552c30b
...
@@ -37,8 +37,14 @@ class AppliedJobsController < ApplicationController
...
@@ -37,8 +37,14 @@ class AppliedJobsController < ApplicationController
return
unless
current_user
.
admin
return
unless
current_user
.
admin
get_data_search_bar
get_data_search_bar
@date
,
@applied_jobs
=
SearchAppliedJob
.
search
(
params
)
@date
,
@applied_jobs
=
SearchAppliedJobsService
.
search
(
params
)
render
'users/applied_jobs'
respond_to
do
|
format
|
format
.
html
{
render
'users/applied_jobs'
}
format
.
csv
{
send_data
ExportCsvService
.
new
(
@applied_jobs
,
AppliedJob
::
CSV_ATTRIBUTES
).
perform
,
filename:
"applied_jobs.csv"
}
end
end
end
private
private
...
...
app/models/applied_job.rb
View file @
4552c30b
class
AppliedJob
<
ApplicationRecord
class
AppliedJob
<
ApplicationRecord
scope
:of_email
,
->
(
email
)
{
where
(
email:
email
)
if
email
.
present?
}
scope
:of_email
,
->
(
email
)
{
where
(
email:
email
)
if
email
.
present?
}
EMAIL_REGEXN
=
/\A[a-zA-Z][\w\.]+@[a-zA-Z]+\.[a-zA-Z]+\z/
EMAIL_REGEXN
=
/\A[a-zA-Z][\w\.]+@[a-zA-Z]+\.[a-zA-Z]+\z/
CSV_ATTRIBUTES
=
%w(job_id job_title email full_name curriculum_vitae created_at)
.
freeze
belongs_to
:user
belongs_to
:user
belongs_to
:job
belongs_to
:job
...
...
app/services/export_csv_service.rb
0 → 100644
View file @
4552c30b
require
'csv'
class
ExportCsvService
def
initialize
(
objects
,
attributes
)
@objects
=
objects
@attributes
=
attributes
end
def
perform
CSV
.
generate
do
|
csv
|
csv
<<
attributes
objects
.
each
do
|
object
|
csv
<<
attributes
.
map
{
|
att
|
object
.
public_send
(
att
)
}
end
end
end
private
attr_reader
:attributes
,
:objects
end
lib/common/search_applied_job
.rb
→
app/services/search_applied_jobs_service
.rb
View file @
4552c30b
module
SearchAppliedJob
module
SearchAppliedJob
sService
def
self
.
search
(
params
)
def
self
.
search
(
params
)
date
=
{}
date
=
{}
if
params
[
:email
].
nil?
if
params
[
:email
].
nil?
...
@@ -9,7 +9,11 @@ module SearchAppliedJob
...
@@ -9,7 +9,11 @@ module SearchAppliedJob
date
[
:from
]
=
Date
.
new
(
params
[
:applied_at
][
"from(1i)"
].
to_i
,
params
[
:applied_at
][
"from(2i)"
].
to_i
,
params
[
:applied_at
][
"from(3i)"
].
to_i
)
date
[
:from
]
=
Date
.
new
(
params
[
:applied_at
][
"from(1i)"
].
to_i
,
params
[
:applied_at
][
"from(2i)"
].
to_i
,
params
[
:applied_at
][
"from(3i)"
].
to_i
)
date
[
:to
]
=
Date
.
new
(
params
[
:applied_at
][
"to(1i)"
].
to_i
,
params
[
:applied_at
][
"to(2i)"
].
to_i
,
params
[
:applied_at
][
"to(3i)"
].
to_i
)
date
[
:to
]
=
Date
.
new
(
params
[
:applied_at
][
"to(1i)"
].
to_i
,
params
[
:applied_at
][
"to(2i)"
].
to_i
,
params
[
:applied_at
][
"to(3i)"
].
to_i
)
job_ids
=
Job
.
of_industry
(
params
[
:industry
]).
of_location
(
params
[
:location
]).
pluck
(
:id
)
job_ids
=
Job
.
of_industry
(
params
[
:industry
]).
of_location
(
params
[
:location
]).
pluck
(
:id
)
applied_jobs
=
AppliedJob
.
includes
(
:job
).
of_email
(
params
[
:email
]).
where
(
created_at:
date
[
:from
]
..
date
[
:to
],
job_id:
job_ids
).
page
(
params
[
:page
])
applied_jobs
=
AppliedJob
.
joins
(
:job
)
.
select
(
"applied_jobs.*, jobs.title as job_title"
)
.
of_email
(
params
[
:email
])
.
where
(
created_at:
date
[
:from
]
..
date
[
:to
],
job_id:
job_ids
)
.
page
(
params
[
:page
])
end
end
[
date
,
applied_jobs
]
[
date
,
applied_jobs
]
end
end
...
...
app/views/users/_applied_job.html.erb
View file @
4552c30b
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
class=
"row"
>
<div
class=
"row"
>
<div
class =
"col-lg-10"
>
<div
class =
"col-lg-10"
>
<div
class=
'card-body'
>
<div
class=
'card-body'
>
<%=
link_to
applied_job
.
job
.
title
,
job_path
(
applied_job
.
job_id
),
class:
'card-title font-weight-bold text-decoration-none'
%>
<%=
link_to
applied_job
.
job
_
title
,
job_path
(
applied_job
.
job_id
),
class:
'card-title font-weight-bold text-decoration-none'
%>
<p><strong>
Candidate Name:
</strong>
<%=
link_to
applied_job
.
full_name
,
user_path
(
applied_job
.
user_id
)
%>
</p>
<p><strong>
Candidate Name:
</strong>
<%=
link_to
applied_job
.
full_name
,
user_path
(
applied_job
.
user_id
)
%>
</p>
<p><strong>
Candidate's CV:
</strong>
<%=
link_to
applied_job
.
curriculum_vitae
.
identifier
,
applied_job
.
curriculum_vitae
.
url
%>
</p>
<p><strong>
Candidate's CV:
</strong>
<%=
link_to
applied_job
.
curriculum_vitae
.
identifier
,
applied_job
.
curriculum_vitae
.
url
%>
</p>
<p><strong>
Candidate's Email:
</strong>
<%=
applied_job
.
email
%>
</p>
<p><strong>
Candidate's Email:
</strong>
<%=
applied_job
.
email
%>
</p>
...
...
app/views/users/applied_jobs.html.erb
View file @
4552c30b
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
{
order:
[
:year
,
:month
,
:day
],
use_month_numbers:
true
,
use_two_digit_numbers:
true
,
selected:
@date
[
:to
]
},
{
order:
[
:year
,
:month
,
:day
],
use_month_numbers:
true
,
use_two_digit_numbers:
true
,
selected:
@date
[
:to
]
},
{
class:
'form-control mx-1'
}
%>
{
class:
'form-control mx-1'
}
%>
</div>
</div>
<%=
submit_tag
'Search'
,
name:
nil
,
class:
'btn btn-outline-success m-2'
%>
<%=
button_tag
'Search'
,
name:
nil
,
type:
'submit'
,
class:
'btn btn-outline-success m-2'
%>
<%=
button_tag
'CSV Download'
,
class:
'btn btn-outline-success m-2'
%>
<%=
button_tag
'CSV Download'
,
value:
'csv'
,
name:
'format'
,
class:
'btn btn-outline-success m-2'
%>
<%
end
%>
<%
end
%>
</div>
</div>
<div
class=
'content'
>
<div
class=
'content'
>
...
...
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