use sidekiq

This commit is contained in:
Pete Matsyburka
2024-06-18 16:51:42 +03:00
parent 9539c476c0
commit 3034c00bb3
41 changed files with 332 additions and 132 deletions
@@ -64,14 +64,14 @@ module Api
submissions = create_submissions(@template, params)
submissions.each do |submission|
SendSubmissionCreatedWebhookRequestJob.perform_later({ 'submission_id' => submission.id })
SendSubmissionCreatedWebhookRequestJob.perform_async({ 'submission_id' => submission.id })
end
Submissions.send_signature_requests(submissions)
submissions.each do |submission|
if submission.submitters.all?(&:completed_at?) && submission.submitters.last
ProcessSubmitterCompletionJob.perform_later({ 'submitter_id' => submission.submitters.last.id })
ProcessSubmitterCompletionJob.perform_async({ 'submitter_id' => submission.submitters.last.id })
end
end
@@ -94,7 +94,7 @@ module Api
else
@submission.update!(archived_at: Time.current)
SendSubmissionArchivedWebhookRequestJob.perform_later('submission_id' => @submission.id)
SendSubmissionArchivedWebhookRequestJob.perform_async('submission_id' => @submission.id)
end
render json: @submission.as_json(only: %i[id archived_at])
@@ -13,7 +13,7 @@ module Api
SubmissionEvents.create_with_tracking_data(submitter, 'view_form', request)
SendFormViewedWebhookRequestJob.perform_later({ 'submitter_id' => submitter.id })
SendFormViewedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id })
render json: {}
end
+1 -1
View File
@@ -66,7 +66,7 @@ module Api
end
if @submitter.completed_at?
ProcessSubmitterCompletionJob.perform_later({ 'submitter_id' => @submitter.id })
ProcessSubmitterCompletionJob.perform_async({ 'submitter_id' => @submitter.id })
elsif normalized_params[:send_email] || normalized_params[:send_sms]
Submitters.send_signature_requests([@submitter])
end
@@ -20,7 +20,7 @@ module Api
Templates::CloneAttachments.call(template: cloned_template, original_template: @template)
SendTemplateCreatedWebhookRequestJob.perform_later('template_id' => cloned_template.id)
SendTemplateCreatedWebhookRequestJob.perform_async('template_id' => cloned_template.id)
render json: Templates::SerializeForApi.call(cloned_template)
end
+1 -1
View File
@@ -65,7 +65,7 @@ module Api
@template.update!(template_params)
SendTemplateUpdatedWebhookRequestJob.perform_later('template_id' => @template.id)
SendTemplateUpdatedWebhookRequestJob.perform_async('template_id' => @template.id)
render json: @template.as_json(only: %i[id updated_at])
end
+1 -1
View File
@@ -37,7 +37,7 @@ class StartFormController < ApplicationController
if @submitter.save
if is_new_record
SendSubmissionCreatedWebhookRequestJob.perform_later({ 'submission_id' => @submitter.submission.id })
SendSubmissionCreatedWebhookRequestJob.perform_async({ 'submission_id' => @submitter.submission.id })
end
redirect_to submit_form_path(@submitter.slug)
+2 -2
View File
@@ -45,7 +45,7 @@ class SubmissionsController < ApplicationController
end
submissions.each do |submission|
SendSubmissionCreatedWebhookRequestJob.perform_later({ 'submission_id' => submission.id })
SendSubmissionCreatedWebhookRequestJob.perform_async({ 'submission_id' => submission.id })
end
Submissions.send_signature_requests(submissions)
@@ -56,7 +56,7 @@ class SubmissionsController < ApplicationController
def destroy
@submission.update!(archived_at: Time.current)
SendSubmissionArchivedWebhookRequestJob.perform_later('submission_id' => @submission.id)
SendSubmissionArchivedWebhookRequestJob.perform_async('submission_id' => @submission.id)
redirect_back(fallback_location: template_path(@submission.template), notice: 'Submission has been archived')
end
@@ -13,7 +13,7 @@ class SubmittersSendEmailController < ApplicationController
alert: 'Email has been sent already.')
end
SendSubmitterInvitationEmailJob.perform_later('submitter_id' => @submitter.id)
SendSubmitterInvitationEmailJob.perform_async('submitter_id' => @submitter.id)
@submitter.sent_at ||= Time.current
@submitter.save!
+2 -2
View File
@@ -61,7 +61,7 @@ class TemplatesController < ApplicationController
if @template.save
Templates::CloneAttachments.call(template: @template, original_template: @base_template) if @base_template
SendTemplateUpdatedWebhookRequestJob.perform_later('template_id' => @template.id)
SendTemplateUpdatedWebhookRequestJob.perform_async('template_id' => @template.id)
maybe_redirect_to_template(@template)
else
@@ -72,7 +72,7 @@ class TemplatesController < ApplicationController
def update
@template.update!(template_params)
SendTemplateUpdatedWebhookRequestJob.perform_later('template_id' => @template.id)
SendTemplateUpdatedWebhookRequestJob.perform_async('template_id' => @template.id)
head :ok
end
@@ -18,7 +18,7 @@ class TemplatesUploadsController < ApplicationController
@template.update!(schema:)
SendTemplateCreatedWebhookRequestJob.perform_later('template_id' => @template.id)
SendTemplateCreatedWebhookRequestJob.perform_async('template_id' => @template.id)
redirect_to edit_template_path(@template)
rescue Templates::CreateAttachments::PdfEncrypted
@@ -17,7 +17,7 @@ class WebhookSettingsController < ApplicationController
def update
submitter = current_account.submitters.where.not(completed_at: nil).order(:id).last
SendFormCompletedWebhookRequestJob.perform_later({ 'submitter_id' => submitter.id })
SendFormCompletedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id })
redirect_back(fallback_location: settings_webhooks_path, notice: 'Webhook request has been sent.')
end