From acef2bf81637bc6a9226195e67a27596723727c2 Mon Sep 17 00:00:00 2001 From: Ryo Takaishi Date: Wed, 27 Nov 2024 19:33:41 +0900 Subject: [PATCH 1/3] fix: stop to active job --- app/controllers/api/v1/check_in_conferences_controller.rb | 2 +- app/jobs/generate_entrysheet_job.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/check_in_conferences_controller.rb b/app/controllers/api/v1/check_in_conferences_controller.rb index 9613f302d..bc97bdc17 100644 --- a/app/controllers/api/v1/check_in_conferences_controller.rb +++ b/app/controllers/api/v1/check_in_conferences_controller.rb @@ -13,7 +13,7 @@ def create check_in_timestamp = Time.zone.at(@params[:checkInTimestamp]) @check_in = CheckInConference.new(profile: attendee, conference:, check_in_timestamp:, scanner_profile_id: @profile.id) conference = Conference.find_by(abbr: @params[:eventAbbr]) - GenerateEntrysheetJob.perform_later(conference.id, attendee.id, speaker&.id, @params[:printerId]) + GenerateEntrysheetJob.perform_now(conference.id, attendee.id, speaker&.id, @params[:printerId]) if @check_in.save render(json: @check_in, status: :created) diff --git a/app/jobs/generate_entrysheet_job.rb b/app/jobs/generate_entrysheet_job.rb index 9f70da5bf..1672e9ca3 100644 --- a/app/jobs/generate_entrysheet_job.rb +++ b/app/jobs/generate_entrysheet_job.rb @@ -44,5 +44,7 @@ def perform(conference_id, profile_id, speaker_id = nil, printer_id = nil) response = client.create_printjob(job) puts("印刷ジョブID: #{response}") + ensure + File.exists?(pdf_file) && File.delete(pdf_file) end end From 1192aaee81c170afa44ca2d489cec1e5c159bcde Mon Sep 17 00:00:00 2001 From: Ryo Takaishi Date: Wed, 27 Nov 2024 19:37:01 +0900 Subject: [PATCH 2/3] fix: rubocop --- app/jobs/generate_entrysheet_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/generate_entrysheet_job.rb b/app/jobs/generate_entrysheet_job.rb index 1672e9ca3..da4acc312 100644 --- a/app/jobs/generate_entrysheet_job.rb +++ b/app/jobs/generate_entrysheet_job.rb @@ -45,6 +45,6 @@ def perform(conference_id, profile_id, speaker_id = nil, printer_id = nil) puts("印刷ジョブID: #{response}") ensure - File.exists?(pdf_file) && File.delete(pdf_file) + File.exist?(pdf_file) && File.delete(pdf_file) end end From 2a4131a582ec0c476c1692f5b9ef42b3adf7f2d2 Mon Sep 17 00:00:00 2001 From: Ryo Takaishi Date: Wed, 27 Nov 2024 19:42:37 +0900 Subject: [PATCH 3/3] fix: test --- spec/requests/api/v1/check_in_conferences_create_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/requests/api/v1/check_in_conferences_create_spec.rb b/spec/requests/api/v1/check_in_conferences_create_spec.rb index 63b8f8b72..6b0d03e85 100644 --- a/spec/requests/api/v1/check_in_conferences_create_spec.rb +++ b/spec/requests/api/v1/check_in_conferences_create_spec.rb @@ -16,6 +16,7 @@ context 'create' do before do allow(JsonWebToken).to(receive(:verify).and_return(alice_claim)) + allow(GenerateEntrysheetJob).to(receive(:perform_now)) end it 'return ok' do