Cast me sync

This commit is contained in:
Senad Uka
2020-07-17 04:50:04 +02:00
parent 96b31b71cf
commit e3acdb4d0e
53 changed files with 678 additions and 635 deletions

View File

@@ -1,4 +1,4 @@
class GenerateInterviewFilesZipJob < ApplicationJob
class GenerateCastingSubmissionFilesZipJob < ApplicationJob
queue_as :default
include Rails.application.routes.url_helpers
include ActionView::Helpers::UrlHelper
@@ -6,12 +6,12 @@ class GenerateInterviewFilesZipJob < ApplicationJob
before_perform do |job|
@project = job.arguments.first
@download = job.arguments.second
@casting_call_interview = job.arguments.third
@casting_submission = job.arguments.third
@download.update!(status: :pending)
end
def perform(project, download, casting_call_interview)
::InterviewFilesCollectionService.new(casting_call_interview.files, @download.name).build do |dir, files|
def perform(project, download, casting_submission)
::CastingSubmissionFilesCollectionService.new(casting_submission.files, @download.name).build do |dir, files|
zipfile_name = "#{dir}/#{@download.name}.zip"
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
files.each do |attachment|
@@ -24,11 +24,11 @@ class GenerateInterviewFilesZipJob < ApplicationJob
rescue StandardError => e
Raven.extra_context(
message: "Failed to generate download for project (##{project.id})",
release_type: "CastingCallInterview"
release_type: "CastingSubmission"
)
@download.failure!
ProjectsChannel.broadcast_download_generation_update(@download, I18n.t("interview_downloads.download.failure"))
ProjectsChannel.broadcast_download_generation_update(@download, I18n.t("casting_submission_downloads.download.failure"))
end
after_perform do |job|
@@ -37,7 +37,7 @@ class GenerateInterviewFilesZipJob < ApplicationJob
downloads_folder_link = link_to("Files > Downloads", project_downloads_path(I18n.locale, @project))
download_button = link_to("Download", rails_blob_path(@download.file, disposition: "attachment", only_path: true), class: "btn btn-success", target: :_blank)
ProjectsChannel.broadcast_download_generation_update(@download, I18n.t("interview_downloads.download.success", downloads_folder_link: downloads_folder_link, download_button: download_button, release_type: "Casting Call Interview"))
ProjectsChannel.broadcast_download_generation_update(@download, I18n.t("casting_submission_downloads.download.success", downloads_folder_link: downloads_folder_link, download_button: download_button, release_type: "Casting Submission"))
end
end
end