Class: EditReceiptsWorker
- Inherits:
-
Object
- Object
- EditReceiptsWorker
- Includes:
- Sidekiq::Job, Workers::StatusBroadcastable
- Defined in:
- app/workers/edit_receipts_worker.rb
Overview
Sidekiq worker: edit receipts.
Instance Attribute Summary
Attributes included from Workers::StatusBroadcastable
Instance Method Summary collapse
Methods included from Workers::StatusBroadcastable::Overrides
Instance Method Details
#perform(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/workers/edit_receipts_worker.rb', line 9 def perform( = {}) = .deep_symbolize_keys excel_file = Upload.find_by(id: [:upload_id]) report = Receipt.edit_receipts_from_xlsx(excel_file) do |current_step, total_steps, | total total_steps at(current_step, ) end excel_file.destroy if report[:errors].any? = report[:errors].join('. ') store redirect_to: '/receipts/edit_from_excel' store error_message: else = report[:successes].join('. ') store redirect_to: "/receipts/edited?edited_receipt_ids%5B%5D=#{report[:edited_receipt_ids].join('&edited_receipt_ids%5B%5D=')}" store message: end end |