-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache PDF on job submission, and download it if available
- Loading branch information
Showing
10 changed files
with
88 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class MakeJobApplicationPdfJob < ApplicationJob | ||
queue_as :low | ||
|
||
def perform(job_application) | ||
pdf = JobApplicationPdfGenerator.new(job_application, job_application.vacancy).generate | ||
pdf_data = pdf.render | ||
|
||
job_application.pdf_version.attach(io: StringIO.open(pdf_data), | ||
filename: "job_application_#{job_application.id}.pdf", | ||
identify: false, | ||
content_type: "application/pdf") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace :vacancy do | ||
desc "backfill all submitted applications to have a PDF version" | ||
|
||
task backfill_application_pdfs: :environment do | ||
Vacancy.expires_within_data_access_period.find_each do |vacancy| | ||
vacancy.job_applications.after_submission.reject { |ja| ja.pdf_version.attached? }.each do |job_application| | ||
MakeJobApplicationPdfJob.perform_later job_application | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe MakeJobApplicationPdfJob do | ||
let(:job_application) { create(:job_application, :status_submitted) } | ||
|
||
it "produces a PDF when called" do | ||
described_class.perform_now job_application | ||
expect(job_application.pdf_version).not_to be_nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters