diff --git a/app/jobs/concerns/failed_delivery_notifiable_job.rb b/app/jobs/concerns/failed_delivery_notifiable_job.rb index ba5458f8b..806f39255 100644 --- a/app/jobs/concerns/failed_delivery_notifiable_job.rb +++ b/app/jobs/concerns/failed_delivery_notifiable_job.rb @@ -14,6 +14,7 @@ module FailedDeliveryNotifiableJob logger.error e.message logger.error e.backtrace.join("\n") create_failed_notification! + raise e end end diff --git a/app/jobs/zip_export_job.rb b/app/jobs/zip_export_job.rb index fbbb2e47c..d7764f1d8 100644 --- a/app/jobs/zip_export_job.rb +++ b/app/jobs/zip_export_job.rb @@ -6,20 +6,18 @@ class ZipExportJob < ApplicationJob def perform(user_id:, params: {}) @user = User.find(user_id) I18n.backend.date_format = @user.settings[:date_format] || Constants::DEFAULT_DATE_FORMAT + zip_input_dir = FileUtils.mkdir_p(Rails.root.join("tmp/temp_zip_#{Time.now.to_i}").to_s).first + zip_dir = FileUtils.mkdir_p(Rails.root.join('tmp/zip-ready').to_s).first + full_zip_name = File.join(zip_dir, zip_name) ZipExport.transaction do @zip_export = ZipExport.create!(user: @user) - zip_input_dir = FileUtils.mkdir_p(Rails.root.join("tmp/temp_zip_#{Time.now.to_i}").to_s).first - zip_dir = FileUtils.mkdir_p(Rails.root.join('tmp/zip-ready').to_s).first - full_zip_name = File.join(zip_dir, zip_name) - fill_content(zip_input_dir, params) @zip_export.zip!(zip_input_dir, full_zip_name) @zip_export.zip_file.attach(io: File.open(full_zip_name), filename: zip_name) generate_notification! - ensure - FileUtils.rm_rf([zip_input_dir, full_zip_name], secure: true) end ensure + FileUtils.rm_rf([zip_input_dir, full_zip_name], secure: true) I18n.backend.date_format = nil end diff --git a/app/services/repository_stock_ledger_zip_export.rb b/app/services/repository_stock_ledger_zip_export.rb index d362fb060..a284879e2 100644 --- a/app/services/repository_stock_ledger_zip_export.rb +++ b/app/services/repository_stock_ledger_zip_export.rb @@ -49,12 +49,13 @@ module RepositoryStockLedgerZipExport def generate_record_data(record) consumption_type = record.reference_type == 'MyModuleRepositoryRow' ? 'Task' : 'Inventory' - if record.amount.positive? - added_amount = record.amount.to_d - added_amount_unit = record.unit - else + if (consumption_type == 'Task' && record.amount.positive?) || + (consumption_type == 'Inventory' && record.amount.negative?) consumed_amount = record.amount.abs.to_d consumed_amount_unit = record.unit + else + added_amount = record.amount.to_d + added_amount_unit = record.unit end breadcrumbs_data = Array.new(4, '') @@ -70,8 +71,8 @@ module RepositoryStockLedgerZipExport record.user.full_name, record.created_at.strftime(record.user.date_format), record.repository_row.repository.team.name, - record.unit, - record.balance.to_d + record.balance.to_d, + record.unit ] if consumption_type == 'Task' diff --git a/config/locales/en.yml b/config/locales/en.yml index ab3a878e6..27a182eaa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3328,6 +3328,7 @@ en: recent_changes: "Recent changes" system_message: "SciNote system message" deliver: 'Exportable content' + deliver_error: 'Exportable content' experiment_annotation_title: "%{user} mentioned you in experiment %{experiment}." experiment_annotation_message_html: "Project: %{project} | Experiment: %{experiment}" project_comment_annotation_title: "%{user} mentioned you in a comment on project %{project}."